Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unlock all servers if lock could not be acquired. #5

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/redlock/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,15 @@ def lock_instances(resource, ttl)
value = SecureRandom.uuid

locked, time_elapsed = timed do
@servers.select { |s| s.lock(resource, value, ttl) }
@servers.select { |s| s.lock(resource, value, ttl) }.size
end

validity = ttl - time_elapsed - drift(ttl)

if locked.size >= @quorum && validity >= 0
if locked >= @quorum && validity >= 0
{ validity: validity, resource: resource, value: value }
else
locked.each { |s| s.unlock(resource, value) }
@servers.each { |s| s.unlock(resource, value) }
false
end
end
Expand Down