Skip to content

Commit 6ce9d2a

Browse files
committed
fix(run-engine): guard the wildcard cleanup in the ck vtime scripts
Carries the fix from #4628 into the three CK scripts this branch adds, which do not exist on main and so could not be covered there. A concurrency key of '*' renders a variant name identical to the wildcard member the master queue uses for the base queue, and the unguarded transition cleanup then removed the entry the rebalance had just written, stranding every concurrency key on that queue. The pre-existing scripts are fixed in #4628; this is the same one-line guard applied to enqueueMessageCkVtimeTracked, enqueueMessageWithTtlCkVtimeTracked and nackMessageCkVtimeTracked.
1 parent 3298ee2 commit 6ce9d2a

1 file changed

Lines changed: 21 additions & 6 deletions

File tree

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

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

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4330,8 +4330,13 @@ if #earliestIdx > 0 then
43304330
redis.call('ZADD', masterQueueKey, earliestIdx[2], ckWildcardName)
43314331
end
43324332
4333-
-- Remove old-format entry from master queue (transition cleanup)
4334-
redis.call('ZREM', masterQueueKey, queueName)
4333+
-- Remove old-format entry from master queue (transition cleanup). Skipped when the
4334+
-- variant name IS the wildcard: a concurrency key of '*' produces a queue key identical
4335+
-- to the wildcard member, so an unguarded ZREM here deletes the entry the rebalance just
4336+
-- wrote and strands every concurrency key on this base queue.
4337+
if queueName ~= ckWildcardName then
4338+
redis.call('ZREM', masterQueueKey, queueName)
4339+
end
43354340
43364341
-- Update the concurrency keys
43374342
redis.call('SREM', queueCurrentConcurrencyKey, messageId)
@@ -4463,8 +4468,13 @@ if #earliestIdx > 0 then
44634468
redis.call('ZADD', masterQueueKey, earliestIdx[2], ckWildcardName)
44644469
end
44654470
4466-
-- Remove old-format entry from master queue (transition cleanup)
4467-
redis.call('ZREM', masterQueueKey, queueName)
4471+
-- Remove old-format entry from master queue (transition cleanup). Skipped when the
4472+
-- variant name IS the wildcard: a concurrency key of '*' produces a queue key identical
4473+
-- to the wildcard member, so an unguarded ZREM here deletes the entry the rebalance just
4474+
-- wrote and strands every concurrency key on this base queue.
4475+
if queueName ~= ckWildcardName then
4476+
redis.call('ZREM', masterQueueKey, queueName)
4477+
end
44684478
44694479
-- Update the concurrency keys
44704480
redis.call('SREM', queueCurrentConcurrencyKey, messageId)
@@ -6141,8 +6151,13 @@ else
61416151
redis.call('ZADD', masterQueueKey, earliestIdx[2], ckWildcardName)
61426152
end
61436153
6144-
-- Remove old-format entry from master queue (transition cleanup)
6145-
redis.call('ZREM', masterQueueKey, messageQueueName)
6154+
-- Remove old-format entry from master queue (transition cleanup). Skipped when the
6155+
-- variant name IS the wildcard: a concurrency key of '*' produces a queue key identical
6156+
-- to the wildcard member, so an unguarded ZREM here deletes the entry the rebalance just
6157+
-- wrote and strands every concurrency key on this base queue.
6158+
if messageQueueName ~= ckWildcardName then
6159+
redis.call('ZREM', masterQueueKey, messageQueueName)
6160+
end
61466161
`,
61476162
});
61486163

0 commit comments

Comments
 (0)