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.
This commit is contained in:
Wes Mason
2026-08-15 03:55:17 +01:00
parent 3f4c27c3f3
commit 129f8d5b86
@@ -4294,8 +4294,13 @@ if #earliestIdx > 0 then
redis.call('ZADD', masterQueueKey, earliestIdx[2], ckWildcardName)
end
-- Remove old-format entry from master queue (transition cleanup)
redis.call('ZREM', masterQueueKey, queueName)
-- Remove old-format entry from master queue (transition cleanup). Skipped when the
-- variant name IS the wildcard: a concurrency key of '*' produces a queue key identical
-- to the wildcard member, so an unguarded ZREM here deletes the entry the rebalance just
-- wrote and strands every concurrency key on this base queue.
if queueName ~= ckWildcardName then
redis.call('ZREM', masterQueueKey, queueName)
end
-- Update the concurrency keys
redis.call('SREM', queueCurrentConcurrencyKey, messageId)
@@ -4427,8 +4432,13 @@ if #earliestIdx > 0 then
redis.call('ZADD', masterQueueKey, earliestIdx[2], ckWildcardName)
end
-- Remove old-format entry from master queue (transition cleanup)
redis.call('ZREM', masterQueueKey, queueName)
-- Remove old-format entry from master queue (transition cleanup). Skipped when the
-- variant name IS the wildcard: a concurrency key of '*' produces a queue key identical
-- to the wildcard member, so an unguarded ZREM here deletes the entry the rebalance just
-- wrote and strands every concurrency key on this base queue.
if queueName ~= ckWildcardName then
redis.call('ZREM', masterQueueKey, queueName)
end
-- Update the concurrency keys
redis.call('SREM', queueCurrentConcurrencyKey, messageId)
@@ -6083,8 +6093,13 @@ else
redis.call('ZADD', masterQueueKey, earliestIdx[2], ckWildcardName)
end
-- Remove old-format entry from master queue (transition cleanup)
redis.call('ZREM', masterQueueKey, messageQueueName)
-- Remove old-format entry from master queue (transition cleanup). Skipped when the
-- variant name IS the wildcard: a concurrency key of '*' produces a queue key identical
-- to the wildcard member, so an unguarded ZREM here deletes the entry the rebalance just
-- wrote and strands every concurrency key on this base queue.
if messageQueueName ~= ckWildcardName then
redis.call('ZREM', masterQueueKey, messageQueueName)
end
`,
});