@@ -349,7 +349,6 @@ export type RunQueueOptions = {
349349 * the total cap covering releases from builds without the mirror.
350350 */
351351 gatesEnabled ?: boolean ;
352- /** Cap on per-concurrency-key limit overrides stored per queue. Default 1000. */
353352 workerOptions ?: {
354353 pollIntervalMs ?: number ;
355354 immediatePollIntervalMs ?: number ;
@@ -1567,6 +1566,7 @@ export class RunQueue {
15671566 runId : string ;
15681567 orgId : string ;
15691568 queue : string ;
1569+ concurrencyKey ?: string ;
15701570 env : RunQueueKeyProducerEnvironment ;
15711571 } ) {
15721572 return this . #callClearMessageFromConcurrencySets( params ) ;
@@ -3108,18 +3108,30 @@ export class RunQueue {
31083108 runId,
31093109 orgId,
31103110 queue,
3111+ concurrencyKey,
31113112 env,
31123113 } : {
31133114 runId : string ;
31143115 orgId : string ;
31153116 queue : string ;
3117+ concurrencyKey ?: string ;
31163118 env : RunQueueKeyProducerEnvironment ;
31173119 } ) {
31183120 const messageId = runId ;
31193121 const messageKey = this . keys . messageKey ( orgId , messageId ) ;
3120- const queueCurrentConcurrencyKey = this . keys . queueCurrentConcurrencyKey ( env , queue ) ;
3122+ /**
3123+ * Callers pass the bare TaskRun queue name plus its concurrencyKey; the run's
3124+ * slots live on the ck variant, and the tracked clear additionally mirrors the
3125+ * group set and counters that only keyed queues maintain.
3126+ */
3127+ const fullQueue = concurrencyKey ? this . keys . queueKey ( env , queue , concurrencyKey ) : queue ;
3128+ const queueCurrentConcurrencyKey = this . keys . queueCurrentConcurrencyKey (
3129+ env ,
3130+ queue ,
3131+ concurrencyKey
3132+ ) ;
31213133 const envCurrentConcurrencyKey = this . keys . envCurrentConcurrencyKey ( env ) ;
3122- const queueCurrentDequeuedKey = this . keys . queueCurrentDequeuedKey ( env , queue ) ;
3134+ const queueCurrentDequeuedKey = this . keys . queueCurrentDequeuedKey ( env , queue , concurrencyKey ) ;
31233135 const envCurrentDequeuedKey = this . keys . envCurrentDequeuedKey ( env ) ;
31243136
31253137 this . logger . debug ( "Calling clearMessageFromConcurrencySets" , {
@@ -3134,15 +3146,15 @@ export class RunQueue {
31343146 service : this . name ,
31353147 } ) ;
31363148
3137- if ( queue . includes ( ":ck:" ) ) {
3149+ if ( fullQueue . includes ( ":ck:" ) ) {
31383150 return this . redis . clearMessageFromConcurrencySetsTracked (
31393151 queueCurrentConcurrencyKey ,
31403152 envCurrentConcurrencyKey ,
31413153 queueCurrentDequeuedKey ,
31423154 envCurrentDequeuedKey ,
3143- this . keys . queueRunningCounterKeyFromQueue ( queue ) ,
3144- this . keys . ckIndexKeyFromQueue ( queue ) ,
3145- this . keys . queueGroupConcurrencyKeyFromQueue ( queue ) ,
3155+ this . keys . queueRunningCounterKeyFromQueue ( fullQueue ) ,
3156+ this . keys . ckIndexKeyFromQueue ( fullQueue ) ,
3157+ this . keys . queueGroupConcurrencyKeyFromQueue ( fullQueue ) ,
31463158 messageKey ,
31473159 messageId ,
31483160 this . options . redis . keyPrefix ?? "" ,
@@ -4229,8 +4241,6 @@ if enableFastPath == '1' then
42294241 tonumber(redis.call('GET', queueConcurrencyLimitKey) or '1000000'),
42304242 envLimit
42314243 )
4232- if totalConcurrencyEnabled then
4233- end
42344244
42354245 if queueCurrent < queueLimit then
42364246 -- Total-cap gate: a fast-path admit consumes a group slot, so it must
@@ -4404,8 +4414,6 @@ if enableFastPath == '1' then
44044414 tonumber(redis.call('GET', queueConcurrencyLimitKey) or '1000000'),
44054415 envLimit
44064416 )
4407- if totalConcurrencyEnabled then
4408- end
44094417
44104418 if queueCurrent < queueLimit then
44114419 -- Total-cap gate: see enqueueMessageCkTracked.
@@ -4900,6 +4908,10 @@ else
49004908 redis.call('ZADD', masterQueueKey, earliestMessage[2], queueName)
49014909end
49024910
4911+ -- Re-sample the gauge so the emitted snapshot includes this batch's admissions;
4912+ -- the top-of-script sample only covers the early returns where nothing was admitted.
4913+ ${ QUEUE_METRICS_GAUGE_LUA }
4914+
49034915-- Return results as a flat array: [messageId1, messageScore1, messagePayload1, messageId2, messageScore2, messagePayload2, ...]
49044916return __qmret(results)
49054917 ` ,
0 commit comments