@@ -331,7 +331,6 @@ export type RunQueueOptions = {
331331 * the total cap covering releases from builds without the mirror.
332332 */
333333 gatesEnabled ?: boolean ;
334- /** Cap on per-concurrency-key limit overrides stored per queue. Default 1000. */
335334 workerOptions ?: {
336335 pollIntervalMs ?: number ;
337336 immediatePollIntervalMs ?: number ;
@@ -1537,6 +1536,7 @@ export class RunQueue {
15371536 runId : string ;
15381537 orgId : string ;
15391538 queue : string ;
1539+ concurrencyKey ?: string ;
15401540 env : RunQueueKeyProducerEnvironment ;
15411541 } ) {
15421542 return this . #callClearMessageFromConcurrencySets( params ) ;
@@ -3068,18 +3068,30 @@ export class RunQueue {
30683068 runId,
30693069 orgId,
30703070 queue,
3071+ concurrencyKey,
30713072 env,
30723073 } : {
30733074 runId : string ;
30743075 orgId : string ;
30753076 queue : string ;
3077+ concurrencyKey ?: string ;
30763078 env : RunQueueKeyProducerEnvironment ;
30773079 } ) {
30783080 const messageId = runId ;
30793081 const messageKey = this . keys . messageKey ( orgId , messageId ) ;
3080- const queueCurrentConcurrencyKey = this . keys . queueCurrentConcurrencyKey ( env , queue ) ;
3082+ /**
3083+ * Callers pass the bare TaskRun queue name plus its concurrencyKey; the run's
3084+ * slots live on the ck variant, and the tracked clear additionally mirrors the
3085+ * group set and counters that only keyed queues maintain.
3086+ */
3087+ const fullQueue = concurrencyKey ? this . keys . queueKey ( env , queue , concurrencyKey ) : queue ;
3088+ const queueCurrentConcurrencyKey = this . keys . queueCurrentConcurrencyKey (
3089+ env ,
3090+ queue ,
3091+ concurrencyKey
3092+ ) ;
30813093 const envCurrentConcurrencyKey = this . keys . envCurrentConcurrencyKey ( env ) ;
3082- const queueCurrentDequeuedKey = this . keys . queueCurrentDequeuedKey ( env , queue ) ;
3094+ const queueCurrentDequeuedKey = this . keys . queueCurrentDequeuedKey ( env , queue , concurrencyKey ) ;
30833095 const envCurrentDequeuedKey = this . keys . envCurrentDequeuedKey ( env ) ;
30843096
30853097 this . logger . debug ( "Calling clearMessageFromConcurrencySets" , {
@@ -3094,15 +3106,15 @@ export class RunQueue {
30943106 service : this . name ,
30953107 } ) ;
30963108
3097- if ( queue . includes ( ":ck:" ) ) {
3109+ if ( fullQueue . includes ( ":ck:" ) ) {
30983110 return this . redis . clearMessageFromConcurrencySetsTracked (
30993111 queueCurrentConcurrencyKey ,
31003112 envCurrentConcurrencyKey ,
31013113 queueCurrentDequeuedKey ,
31023114 envCurrentDequeuedKey ,
3103- this . keys . queueRunningCounterKeyFromQueue ( queue ) ,
3104- this . keys . ckIndexKeyFromQueue ( queue ) ,
3105- this . keys . queueGroupConcurrencyKeyFromQueue ( queue ) ,
3115+ this . keys . queueRunningCounterKeyFromQueue ( fullQueue ) ,
3116+ this . keys . ckIndexKeyFromQueue ( fullQueue ) ,
3117+ this . keys . queueGroupConcurrencyKeyFromQueue ( fullQueue ) ,
31063118 messageKey ,
31073119 messageId ,
31083120 this . options . redis . keyPrefix ?? "" ,
@@ -4127,8 +4139,6 @@ if enableFastPath == '1' then
41274139 tonumber(redis.call('GET', queueConcurrencyLimitKey) or '1000000'),
41284140 envLimit
41294141 )
4130- if totalConcurrencyEnabled then
4131- end
41324142
41334143 if queueCurrent < queueLimit then
41344144 -- Total-cap gate: a fast-path admit consumes a group slot, so it must
@@ -4302,8 +4312,6 @@ if enableFastPath == '1' then
43024312 tonumber(redis.call('GET', queueConcurrencyLimitKey) or '1000000'),
43034313 envLimit
43044314 )
4305- if totalConcurrencyEnabled then
4306- end
43074315
43084316 if queueCurrent < queueLimit then
43094317 -- Total-cap gate: see enqueueMessageCkTracked.
@@ -4769,6 +4777,10 @@ else
47694777 redis.call('ZADD', masterQueueKey, earliestMessage[2], queueName)
47704778end
47714779
4780+ -- Re-sample the gauge so the emitted snapshot includes this batch's admissions;
4781+ -- the top-of-script sample only covers the early returns where nothing was admitted.
4782+ ${ QUEUE_METRICS_GAUGE_LUA }
4783+
47724784-- Return results as a flat array: [messageId1, messageScore1, messagePayload1, messageId2, messageScore2, messagePayload2, ...]
47734785return __qmret(results)
47744786 ` ,
0 commit comments