about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2011-11-10 01:16:20 +0000
committerEric Wong <normalperson@yhbt.net>2011-11-10 01:16:20 +0000
commit39202060afca2be96c1d01dd83b738de0bd2cc7f (patch)
treea25c55309ad3a5aec20c9761e5fcaf306b6ad4f5
parent265f3d32126cf2a31587a6021494f528bbdf8171 (diff)
downloadmogilefs-client-39202060afca2be96c1d01dd83b738de0bd2cc7f.tar.gz
We don't want to blindly retry on invalid keys and such,
only on invalid (truncated) responses, timeouts, and
syscall errors.
-rw-r--r--lib/mogilefs/backend.rb14
1 files changed, 11 insertions, 3 deletions
diff --git a/lib/mogilefs/backend.rb b/lib/mogilefs/backend.rb
index b0d2f5b..8b9dc6d 100644
--- a/lib/mogilefs/backend.rb
+++ b/lib/mogilefs/backend.rb
@@ -181,12 +181,20 @@ class MogileFS::Backend
 
         idempotent or
           raise EOFError, "end of file reached after: #{request.inspect}"
-      rescue
+      rescue SystemCallError,
+             MogileFS::UnreadableSocketError,
+             MogileFS::InvalidResponseError, # truncated response
+             MogileFS::Timeout
+        # we got a successful timed_write, but not a timed_gets
+        retry if idempotent
+        shutdown_unlocked
+        raise
+      rescue => err
         # we DO NOT want the response we timed out waiting for, to crop up later
         # on, on the same socket, intersperesed with a subsequent request!  we
         # close the socket if there's any error.
         shutdown_unlocked
-        idempotent or raise
+        raise
       end while idempotent
     end # @mutex.synchronize
   end
@@ -238,7 +246,7 @@ class MogileFS::Backend
         addr, port = host.split(/:/)
         @socket = MogileFS::Socket.tcp(addr, port, @timeout)
         @active_host = host
-      rescue SystemCallError, MogileFS::Timeout
+      rescue SystemCallError, MogileFS::Timeout => err
         @dead[host] = now
         next
       end