Skip to content

Commit

Permalink
Merge pull request #5 from keylimetoolbox/double-initial-set
Browse files Browse the repository at this point in the history
Fix #initial_set which is causing a double attempt and delay on lock acquisition and incorrect drop on short acquisition_timeout
  • Loading branch information
nickelser authored Oct 5, 2018
2 parents 152b6ac + a13edcf commit 8ed488f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
10 changes: 2 additions & 8 deletions lib/suo/client/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,7 @@ def refresh(token)
retry_with_timeout do
val, cas = get

if val.nil?
initial_set
next
end
cas = initial_set if val.nil?

cleared_locks = deserialize_and_clear_locks(val)

Expand Down Expand Up @@ -102,10 +99,7 @@ def acquire_lock(token = nil)
retry_with_timeout do
val, cas = get

if val.nil?
initial_set
next
end
cas = initial_set if val.nil?

cleared_locks = deserialize_and_clear_locks(val)

Expand Down
2 changes: 2 additions & 0 deletions lib/suo/client/memcached.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ def set(newval, cas, expire: false)

def initial_set(val = BLANK_STR)
@client.set(@key, val)
_val, cas = @client.get_cas(@key)
cas
end
end
end
Expand Down
3 changes: 2 additions & 1 deletion lib/suo/client/redis.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ def synchronize
end

def initial_set(val = BLANK_STR)
@client.set(@key, val)
set(val, nil)
nil
end
end
end
Expand Down

0 comments on commit 8ed488f

Please sign in to comment.