@@ -323,7 +323,6 @@ export type RunQueueOptions = {
323323 * the total cap covering releases from builds without the mirror.
324324 */
325325 gatesEnabled ?: boolean ;
326- /** Cap on per-concurrency-key limit overrides stored per queue. Default 1000. */
327326 workerOptions ?: {
328327 pollIntervalMs ?: number ;
329328 immediatePollIntervalMs ?: number ;
@@ -1529,6 +1528,7 @@ export class RunQueue {
15291528 runId : string ;
15301529 orgId : string ;
15311530 queue : string ;
1531+ concurrencyKey ?: string ;
15321532 env : RunQueueKeyProducerEnvironment ;
15331533 } ) {
15341534 return this . #callClearMessageFromConcurrencySets( params ) ;
@@ -3060,18 +3060,30 @@ export class RunQueue {
30603060 runId,
30613061 orgId,
30623062 queue,
3063+ concurrencyKey,
30633064 env,
30643065 } : {
30653066 runId : string ;
30663067 orgId : string ;
30673068 queue : string ;
3069+ concurrencyKey ?: string ;
30683070 env : RunQueueKeyProducerEnvironment ;
30693071 } ) {
30703072 const messageId = runId ;
30713073 const messageKey = this . keys . messageKey ( orgId , messageId ) ;
3072- const queueCurrentConcurrencyKey = this . keys . queueCurrentConcurrencyKey ( env , queue ) ;
3074+ /**
3075+ * Callers pass the bare TaskRun queue name plus its concurrencyKey; the run's
3076+ * slots live on the ck variant, and the tracked clear additionally mirrors the
3077+ * group set and counters that only keyed queues maintain.
3078+ */
3079+ const fullQueue = concurrencyKey ? this . keys . queueKey ( env , queue , concurrencyKey ) : queue ;
3080+ const queueCurrentConcurrencyKey = this . keys . queueCurrentConcurrencyKey (
3081+ env ,
3082+ queue ,
3083+ concurrencyKey
3084+ ) ;
30733085 const envCurrentConcurrencyKey = this . keys . envCurrentConcurrencyKey ( env ) ;
3074- const queueCurrentDequeuedKey = this . keys . queueCurrentDequeuedKey ( env , queue ) ;
3086+ const queueCurrentDequeuedKey = this . keys . queueCurrentDequeuedKey ( env , queue , concurrencyKey ) ;
30753087 const envCurrentDequeuedKey = this . keys . envCurrentDequeuedKey ( env ) ;
30763088
30773089 this . logger . debug ( "Calling clearMessageFromConcurrencySets" , {
@@ -3086,15 +3098,15 @@ export class RunQueue {
30863098 service : this . name ,
30873099 } ) ;
30883100
3089- if ( queue . includes ( ":ck:" ) ) {
3101+ if ( fullQueue . includes ( ":ck:" ) ) {
30903102 return this . redis . clearMessageFromConcurrencySetsTracked (
30913103 queueCurrentConcurrencyKey ,
30923104 envCurrentConcurrencyKey ,
30933105 queueCurrentDequeuedKey ,
30943106 envCurrentDequeuedKey ,
3095- this . keys . queueRunningCounterKeyFromQueue ( queue ) ,
3096- this . keys . ckIndexKeyFromQueue ( queue ) ,
3097- this . keys . queueGroupConcurrencyKeyFromQueue ( queue ) ,
3107+ this . keys . queueRunningCounterKeyFromQueue ( fullQueue ) ,
3108+ this . keys . ckIndexKeyFromQueue ( fullQueue ) ,
3109+ this . keys . queueGroupConcurrencyKeyFromQueue ( fullQueue ) ,
30983110 messageKey ,
30993111 messageId ,
31003112 this . options . redis . keyPrefix ?? "" ,
@@ -4119,8 +4131,6 @@ if enableFastPath == '1' then
41194131 tonumber(redis.call('GET', queueConcurrencyLimitKey) or '1000000'),
41204132 envLimit
41214133 )
4122- if totalConcurrencyEnabled then
4123- end
41244134
41254135 if queueCurrent < queueLimit then
41264136 -- Total-cap gate: a fast-path admit consumes a group slot, so it must
@@ -4294,8 +4304,6 @@ if enableFastPath == '1' then
42944304 tonumber(redis.call('GET', queueConcurrencyLimitKey) or '1000000'),
42954305 envLimit
42964306 )
4297- if totalConcurrencyEnabled then
4298- end
42994307
43004308 if queueCurrent < queueLimit then
43014309 -- Total-cap gate: see enqueueMessageCkTracked.
@@ -4761,6 +4769,10 @@ else
47614769 redis.call('ZADD', masterQueueKey, earliestMessage[2], queueName)
47624770end
47634771
4772+ -- Re-sample the gauge so the emitted snapshot includes this batch's admissions;
4773+ -- the top-of-script sample only covers the early returns where nothing was admitted.
4774+ ${ QUEUE_METRICS_GAUGE_LUA }
4775+
47644776-- Return results as a flat array: [messageId1, messageScore1, messagePayload1, messageId2, messageScore2, messagePayload2, ...]
47654777return __qmret(results)
47664778 ` ,
0 commit comments