about summary refs log tree commit homepage
path: root/lib/mogilefs/new_file_common.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/mogilefs/new_file_common.rb')
-rw-r--r--lib/mogilefs/new_file_common.rb14
1 files changed, 13 insertions, 1 deletions
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