@@ -3603,8 +3603,13 @@ if #earliestIdx > 0 then
36033603 redis.call('ZADD', masterQueueKey, earliestIdx[2], ckWildcardName)
36043604end
36053605
3606- -- Remove old-format entry from master queue (transition cleanup)
3607- redis.call('ZREM', masterQueueKey, queueName)
3606+ -- Remove old-format entry from master queue (transition cleanup). Skipped when the
3607+ -- variant name IS the wildcard: a concurrency key of '*' produces a queue key identical
3608+ -- to the wildcard member, so an unguarded ZREM here deletes the entry the rebalance just
3609+ -- wrote and strands every concurrency key on this base queue.
3610+ if queueName ~= ckWildcardName then
3611+ redis.call('ZREM', masterQueueKey, queueName)
3612+ end
36083613
36093614-- Update the concurrency keys
36103615redis.call('SREM', queueCurrentConcurrencyKey, messageId)
@@ -3708,8 +3713,13 @@ if #earliestIdx > 0 then
37083713 redis.call('ZADD', masterQueueKey, earliestIdx[2], ckWildcardName)
37093714end
37103715
3711- -- Remove old-format entry from master queue (transition cleanup)
3712- redis.call('ZREM', masterQueueKey, queueName)
3716+ -- Remove old-format entry from master queue (transition cleanup). Skipped when the
3717+ -- variant name IS the wildcard: a concurrency key of '*' produces a queue key identical
3718+ -- to the wildcard member, so an unguarded ZREM here deletes the entry the rebalance just
3719+ -- wrote and strands every concurrency key on this base queue.
3720+ if queueName ~= ckWildcardName then
3721+ redis.call('ZREM', masterQueueKey, queueName)
3722+ end
37133723
37143724-- Update the concurrency keys
37153725redis.call('SREM', queueCurrentConcurrencyKey, messageId)
@@ -3838,8 +3848,13 @@ if #earliestIdx > 0 then
38383848 redis.call('ZADD', masterQueueKey, earliestIdx[2], ckWildcardName)
38393849end
38403850
3841- -- Remove old-format entry from master queue (transition cleanup)
3842- redis.call('ZREM', masterQueueKey, queueName)
3851+ -- Remove old-format entry from master queue (transition cleanup). Skipped when the
3852+ -- variant name IS the wildcard: a concurrency key of '*' produces a queue key identical
3853+ -- to the wildcard member, so an unguarded ZREM here deletes the entry the rebalance just
3854+ -- wrote and strands every concurrency key on this base queue.
3855+ if queueName ~= ckWildcardName then
3856+ redis.call('ZREM', masterQueueKey, queueName)
3857+ end
38433858
38443859-- Update the concurrency keys
38453860redis.call('SREM', queueCurrentConcurrencyKey, messageId)
@@ -3956,8 +3971,13 @@ if #earliestIdx > 0 then
39563971 redis.call('ZADD', masterQueueKey, earliestIdx[2], ckWildcardName)
39573972end
39583973
3959- -- Remove old-format entry from master queue (transition cleanup)
3960- redis.call('ZREM', masterQueueKey, queueName)
3974+ -- Remove old-format entry from master queue (transition cleanup). Skipped when the
3975+ -- variant name IS the wildcard: a concurrency key of '*' produces a queue key identical
3976+ -- to the wildcard member, so an unguarded ZREM here deletes the entry the rebalance just
3977+ -- wrote and strands every concurrency key on this base queue.
3978+ if queueName ~= ckWildcardName then
3979+ redis.call('ZREM', masterQueueKey, queueName)
3980+ end
39613981
39623982-- Update the concurrency keys
39633983redis.call('SREM', queueCurrentConcurrencyKey, messageId)
@@ -4908,8 +4928,13 @@ else
49084928 redis.call('ZADD', masterQueueKey, earliestInCkIndex[2], ckWildcardName)
49094929end
49104930
4911- -- Remove old-format entry from master queue (transition cleanup)
4912- redis.call('ZREM', masterQueueKey, messageQueueName)
4931+ -- Remove old-format entry from master queue (transition cleanup). Skipped when the
4932+ -- variant name IS the wildcard: a concurrency key of '*' produces a queue key identical
4933+ -- to the wildcard member, so an unguarded ZREM here deletes the entry the rebalance just
4934+ -- wrote and strands every concurrency key on this base queue.
4935+ if messageQueueName ~= ckWildcardName then
4936+ redis.call('ZREM', masterQueueKey, messageQueueName)
4937+ end
49134938
49144939-- Update the concurrency keys
49154940redis.call('SREM', queueCurrentConcurrencyKey, messageId)
@@ -4973,8 +4998,13 @@ else
49734998 redis.call('ZADD', masterQueueKey, earliestIdx[2], ckWildcardName)
49744999end
49755000
4976- -- Remove old-format entry from master queue (transition cleanup)
4977- redis.call('ZREM', masterQueueKey, messageQueueName)
5001+ -- Remove old-format entry from master queue (transition cleanup). Skipped when the
5002+ -- variant name IS the wildcard: a concurrency key of '*' produces a queue key identical
5003+ -- to the wildcard member, so an unguarded ZREM here deletes the entry the rebalance just
5004+ -- wrote and strands every concurrency key on this base queue.
5005+ if messageQueueName ~= ckWildcardName then
5006+ redis.call('ZREM', masterQueueKey, messageQueueName)
5007+ end
49785008` ,
49795009 } ) ;
49805010
@@ -5019,8 +5049,13 @@ else
50195049 redis.call('ZADD', masterQueueKey, earliestIdx[2], ckWildcardName)
50205050end
50215051
5022- -- Remove old-format entry from master queue (transition cleanup)
5023- redis.call('ZREM', masterQueueKey, messageQueueName)
5052+ -- Remove old-format entry from master queue (transition cleanup). Skipped when the
5053+ -- variant name IS the wildcard: a concurrency key of '*' produces a queue key identical
5054+ -- to the wildcard member, so an unguarded ZREM here deletes the entry the rebalance just
5055+ -- wrote and strands every concurrency key on this base queue.
5056+ if messageQueueName ~= ckWildcardName then
5057+ redis.call('ZREM', masterQueueKey, messageQueueName)
5058+ end
50245059
50255060-- Add the message to the dead letter queue
50265061redis.call('ZADD', deadLetterQueueKey, tonumber(redis.call('TIME')[1]), messageId)
@@ -5095,8 +5130,13 @@ else
50955130 redis.call('ZADD', masterQueueKey, earliestInCkIndex[2], ckWildcardName)
50965131end
50975132
5098- -- Remove old-format entry from master queue (transition cleanup)
5099- redis.call('ZREM', masterQueueKey, messageQueueName)
5133+ -- Remove old-format entry from master queue (transition cleanup). Skipped when the
5134+ -- variant name IS the wildcard: a concurrency key of '*' produces a queue key identical
5135+ -- to the wildcard member, so an unguarded ZREM here deletes the entry the rebalance just
5136+ -- wrote and strands every concurrency key on this base queue.
5137+ if messageQueueName ~= ckWildcardName then
5138+ redis.call('ZREM', masterQueueKey, messageQueueName)
5139+ end
51005140
51015141-- Update the concurrency keys. DECR runningCounter only when SREM
51025142-- currentDequeued actually removed an entry (the message was in flight).
@@ -5201,8 +5241,13 @@ else
52015241 redis.call('ZADD', masterQueueKey, earliestIdx[2], ckWildcardName)
52025242end
52035243
5204- -- Remove old-format entry from master queue (transition cleanup)
5205- redis.call('ZREM', masterQueueKey, messageQueueName)
5244+ -- Remove old-format entry from master queue (transition cleanup). Skipped when the
5245+ -- variant name IS the wildcard: a concurrency key of '*' produces a queue key identical
5246+ -- to the wildcard member, so an unguarded ZREM here deletes the entry the rebalance just
5247+ -- wrote and strands every concurrency key on this base queue.
5248+ if messageQueueName ~= ckWildcardName then
5249+ redis.call('ZREM', masterQueueKey, messageQueueName)
5250+ end
52065251` ,
52075252 } ) ;
52085253
@@ -5261,8 +5306,13 @@ else
52615306 redis.call('ZADD', masterQueueKey, earliestIdx[2], ckWildcardName)
52625307end
52635308
5264- -- Remove old-format entry from master queue (transition cleanup)
5265- redis.call('ZREM', masterQueueKey, messageQueueName)
5309+ -- Remove old-format entry from master queue (transition cleanup). Skipped when the
5310+ -- variant name IS the wildcard: a concurrency key of '*' produces a queue key identical
5311+ -- to the wildcard member, so an unguarded ZREM here deletes the entry the rebalance just
5312+ -- wrote and strands every concurrency key on this base queue.
5313+ if messageQueueName ~= ckWildcardName then
5314+ redis.call('ZREM', masterQueueKey, messageQueueName)
5315+ end
52665316
52675317-- Add the message to the dead letter queue
52685318redis.call('ZADD', deadLetterQueueKey, tonumber(redis.call('TIME')[1]), messageId)
0 commit comments