From 129f8d5b86885feee4939fc05c71259cc70e2078 Mon Sep 17 00:00:00 2001 From: Wes Mason Date: Sat, 15 Aug 2026 03:55:17 +0100 Subject: [PATCH] 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. --- .../run-engine/src/run-queue/index.ts | 27 ++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/internal-packages/run-engine/src/run-queue/index.ts b/internal-packages/run-engine/src/run-queue/index.ts index 810013833..26ec1dd99 100644 --- a/internal-packages/run-engine/src/run-queue/index.ts +++ b/internal-packages/run-engine/src/run-queue/index.ts @@ -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 `, });