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 `, });