Skip to content

Commit c5d5b3d

Browse files
committed
clean the cleanup script
1 parent d063248 commit c5d5b3d

File tree

1 file changed

+2
-12
lines changed

1 file changed

+2
-12
lines changed

packages/service-library/src/servicelib/redis/lua/cleanup_fair_semaphore_v2.lua

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
-- KEYS[3]: holder_prefix (prefix for holder keys, e.g. "semaphores:holders:key:")
55
-- ARGV[1]: capacity (total semaphore capacity)
66
--
7-
-- Returns: {recovered_tokens, current_holders, available_tokens, total_cleaned}
7+
-- Returns: {recovered_tokens, missing_tokens, excess_tokens}
88
-- This script should be run periodically to recover tokens from crashed clients
99

1010
local tokens_key = KEYS[1]
@@ -52,15 +52,5 @@ for i = 1, excess_tokens do
5252
redis.call('RPOP', tokens_key)
5353
end
5454

55-
-- Step 4: Refresh expiry on data structures to prevent cleanup
56-
local final_holders = redis.call('SCARD', holders_key)
57-
local final_available = redis.call('LLEN', tokens_key)
5855

59-
if final_holders > 0 then
60-
redis.call('EXPIRE', holders_key, 3600) -- 1 hour expiry
61-
end
62-
if final_available > 0 then
63-
redis.call('EXPIRE', tokens_key, 3600) -- 1 hour expiry
64-
end
65-
66-
return {recovered_tokens, final_holders, final_available, #cleaned_holders}
56+
return {recovered_tokens, missing_tokens, excess_tokens}

0 commit comments

Comments
 (0)