Permalink
Browse files

Handle occasional command error when discarding a transaction.

There seems to be a bug in the Redis client, where a multi may return without
successfully executing the call. Only appears to happen when redis is
persisting.
  • Loading branch information...
1 parent ac03d44 commit 22fa430da5d8aadf2199c48358233fefb7a10c5a @oggy oggy committed Aug 5, 2012
Showing with 7 additions and 1 deletion.
  1. +7 −1 lib/redness/red.rb
View
@@ -31,7 +31,13 @@ def multi_with_caution(fail_return = [])
yield
redis.exec
rescue
- redis.discard
+ begin
+ redis.discard
+ rescue Redis::CommandError
+ # It's possible the multi failed, but didn't raise an exception -
+ # perhaps due to write(2) not being reattempted in the redis client
+ # (likely a bug).
+ end
fail_return
end
end

0 comments on commit 22fa430

Please sign in to comment.