Skip to content

Commit 129f8d5

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 3f4c27c commit 129f8d5

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
@@ -4294,8 +4294,13 @@ if #earliestIdx > 0 then
42944294
redis.call('ZADD', masterQueueKey, earliestIdx[2], ckWildcardName)
42954295
end
42964296
4297-
-- Remove old-format entry from master queue (transition cleanup)
4298-
redis.call('ZREM', masterQueueKey, queueName)
4297+
-- Remove old-format entry from master queue (transition cleanup). Skipped when the
4298+
-- variant name IS the wildcard: a concurrency key of '*' produces a queue key identical
4299+
-- to the wildcard member, so an unguarded ZREM here deletes the entry the rebalance just
4300+
-- wrote and strands every concurrency key on this base queue.
4301+
if queueName ~= ckWildcardName then
4302+
redis.call('ZREM', masterQueueKey, queueName)
4303+
end
42994304
43004305
-- Update the concurrency keys
43014306
redis.call('SREM', queueCurrentConcurrencyKey, messageId)
@@ -4427,8 +4432,13 @@ if #earliestIdx > 0 then
44274432
redis.call('ZADD', masterQueueKey, earliestIdx[2], ckWildcardName)
44284433
end
44294434
4430-
-- Remove old-format entry from master queue (transition cleanup)
4431-
redis.call('ZREM', masterQueueKey, queueName)
4435+
-- Remove old-format entry from master queue (transition cleanup). Skipped when the
4436+
-- variant name IS the wildcard: a concurrency key of '*' produces a queue key identical
4437+
-- to the wildcard member, so an unguarded ZREM here deletes the entry the rebalance just
4438+
-- wrote and strands every concurrency key on this base queue.
4439+
if queueName ~= ckWildcardName then
4440+
redis.call('ZREM', masterQueueKey, queueName)
4441+
end
44324442
44334443
-- Update the concurrency keys
44344444
redis.call('SREM', queueCurrentConcurrencyKey, messageId)
@@ -6083,8 +6093,13 @@ else
60836093
redis.call('ZADD', masterQueueKey, earliestIdx[2], ckWildcardName)
60846094
end
60856095
6086-
-- Remove old-format entry from master queue (transition cleanup)
6087-
redis.call('ZREM', masterQueueKey, messageQueueName)
6096+
-- Remove old-format entry from master queue (transition cleanup). Skipped when the
6097+
-- variant name IS the wildcard: a concurrency key of '*' produces a queue key identical
6098+
-- to the wildcard member, so an unguarded ZREM here deletes the entry the rebalance just
6099+
-- wrote and strands every concurrency key on this base queue.
6100+
if messageQueueName ~= ckWildcardName then
6101+
redis.call('ZREM', masterQueueKey, messageQueueName)
6102+
end
60886103
`,
60896104
});
60906105

0 commit comments

Comments
 (0)