From 83aa5dede6f0f9b04a631d0875d3e4d4f7927a8c Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 9 Dec 2011 11:35:25 +0000 Subject: new_file_common: call "noop" before "create_close" An upload could've taken a long time, ping and try to ensure socket is valid to minimize (but not completely eliminate) the chance create_close hits a stale socket (while reading the response after writing to it) and becomes non-retryable. We treat create_close specially as its less idempotent than any other command (even other non-idempotent ones). There may be no hope of retrying the upload at all if data was streamed and calling create_close twice will hurt us... --- lib/mogilefs/backend.rb | 1 + lib/mogilefs/new_file_common.rb | 14 +++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/mogilefs/backend.rb b/lib/mogilefs/backend.rb index b48764c..e546350 100644 --- a/lib/mogilefs/backend.rb +++ b/lib/mogilefs/backend.rb @@ -98,6 +98,7 @@ class MogileFS::Backend add_command :create_open add_command :create_close add_idempotent_command :get_paths + add_idempotent_command :noop add_command :delete add_idempotent_command :sleep add_command :rename diff --git a/lib/mogilefs/new_file_common.rb b/lib/mogilefs/new_file_common.rb index c0bdc81..9db6aec 100644 --- a/lib/mogilefs/new_file_common.rb +++ b/lib/mogilefs/new_file_common.rb @@ -48,7 +48,19 @@ module MogileFS::NewFileCommon args[:checksum] = "MD5:#{hex}" end args[:checksumverify] = 1 if @opts[:checksumverify] - @opts[:backend].create_close(args) + backend = @opts[:backend] + + # upload could've taken a long time, ping and try to ensure socket + # is valid to minimize (but not completely eliminate) the chance + # create_close hits a stale socket (while reading the response after + # writing to it) and becomes non-retryable. We treat create_close + # specially as its less idempotent than any other command + # (even other non-idempotent ones). There may be no hope of retrying + # the upload at all if data was streamed and calling create_close + # twice will hurt us... + backend.noop + + backend.create_close(args) bytes_uploaded end -- cgit v1.2.3-24-ge0c7