Skip to content

Commit 7d1b7ae

Browse files
committed
fix(run-engine): the TTL sweep's defensive removal drains the group set for keyless queues
The defensive currentConcurrency removal in the TTL expiry script now mirrors into the base groupConcurrency set whether or not the queue is keyed, closing the last live release path where the mirror was conditional on the queue shape instead of the removal itself.
1 parent dc7b494 commit 7d1b7ae

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

  • internal-packages/run-engine/src/run-queue

‎internal-packages/run-engine/src/run-queue/index.ts‎

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4709,8 +4709,16 @@ for i, member in ipairs(expiredMembers) do
47094709
redis.call('SREM', envConcurrencyKey, runId)
47104710
redis.call('SREM', envDequeuedKey, runId)
47114711
4712-
-- Rebalance CK index AND update counters if this is a CK queue
4712+
-- Mirror the currentConcurrency SREM into the base groupConcurrency set for
4713+
-- keyed and keyless queues alike, so a defensive removal always drains the
4714+
-- total pool too.
47134715
local ckMatch = string.match(rawQueueKey, "(.-):ck:")
4716+
if removedFromCurrent == 1 then
4717+
local groupBase = ckMatch or rawQueueKey
4718+
redis.call('SREM', keyPrefix .. groupBase .. ":groupConcurrency", runId)
4719+
end
4720+
4721+
-- Rebalance CK index AND update counters if this is a CK queue
47144722
if ckMatch then
47154723
local lengthCounterKey = keyPrefix .. ckMatch .. ":lengthCounter"
47164724
local runningCounterKey = keyPrefix .. ckMatch .. ":runningCounter"
@@ -4720,10 +4728,6 @@ for i, member in ipairs(expiredMembers) do
47204728
if removedFromDequeued == 1 then
47214729
decrFloored(runningCounterKey)
47224730
end
4723-
-- Mirror the per-CK currentConcurrency SREM into the base groupConcurrency set
4724-
if removedFromCurrent == 1 then
4725-
redis.call('SREM', keyPrefix .. ckMatch .. ":groupConcurrency", runId)
4726-
end
47274731
47284732
local ckIndexKey = keyPrefix .. ckMatch .. ":ckIndex"
47294733
local earliest = redis.call('ZRANGE', queueKey, 0, 0, 'WITHSCORES')

0 commit comments

Comments
 (0)