Permalink
Browse files

Stop repeated attempts to acquire exclusive lock in Node Manager (#36)

  • Loading branch information...
1 parent 2350f3e commit 4be71f18b0a93e36cfb59e0746a10a85e49b15ce @ryanlecompte committed Oct 3, 2012
Showing with 13 additions and 2 deletions.
  1. +4 −0 Changes.md
  2. +9 −2 lib/redis_failover/node_manager.rb
View
@@ -1,3 +1,7 @@
+HEAD
+-----------
+- Stop repeated attempts to acquire exclusive lock in Node Manager (#36)
+
0.9.7
-----------
- Stubbed Client#client to return itself, fixes a fork reconnect bug with Resque (dbalatero)
@@ -95,6 +95,9 @@ def shutdown
logger.info('Shutting down ...')
@mutex.synchronize do
@shutdown = true
+ unless @leader
+ reset
+ end
end
end
@@ -406,8 +409,12 @@ def write_state
# Executes a block wrapped in a ZK exclusive lock.
def with_lock
@zk_lock = @zk.locker(@lock_path)
- while running? && !@zk_lock.lock
- sleep(TIMEOUT)
+
+ begin
+ @zk_lock.lock!(true)
+ rescue Exception
+ # handle shutdown case
+ running? ? raise : return
end
if running?

0 comments on commit 4be71f1

Please sign in to comment.