Skip to content

Commit

Permalink
fix(unlock): make cleanup more aggressive
Browse files Browse the repository at this point in the history
  • Loading branch information
mhenrixon committed Feb 7, 2024
1 parent bc058f4 commit cddcc08
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions lib/sidekiq_unique_jobs/lua/unlock.lua
Original file line number Diff line number Diff line change
Expand Up @@ -75,21 +75,28 @@ if lock_type ~= "until_expired" then
redis.call("HDEL", locked, job_id)
end

if redis.call("LLEN", primed) == 0 then
log_debug("UNLINK", primed)
redis.call("UNLINK", primed)
end

local locked_count = redis.call("HLEN", locked)

if locked_count and locked_count < 1 then
if locked_count < 1 then
log_debug("UNLINK", locked)
redis.call("UNLINK", locked)
end

if redis.call("LLEN", primed) == 0 then
log_debug("UNLINK", primed)
redis.call("UNLINK", primed)
end

if limit and limit <= 1 and locked_count and locked_count <= 1 then
log_debug("ZREM", digests, digest)
redis.call("ZREM", digests, digest)
if limit then
if limit <= 1 and locked_count <= 1 then
log_debug("ZREM", digests, digest)
redis.call("ZREM", digests, digest)
end
else
if locked_count <= 1 then
log_debug("ZREM", digests, digest)
redis.call("ZREM", digests, digest)
end
end

log_debug("LPUSH", queued, "1")
Expand Down

0 comments on commit cddcc08

Please sign in to comment.