@@ -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 ;
@@ -1549,6 +1548,7 @@ export class RunQueue {
15491548 runId : string ;
15501549 orgId : string ;
15511550 queue : string ;
1551+ concurrencyKey ?: string ;
15521552 env : RunQueueKeyProducerEnvironment ;
15531553 } ) {
15541554 return this . #callClearMessageFromConcurrencySets( params ) ;
@@ -3084,18 +3084,30 @@ export class RunQueue {
30843084 runId,
30853085 orgId,
30863086 queue,
3087+ concurrencyKey,
30873088 env,
30883089 } : {
30893090 runId : string ;
30903091 orgId : string ;
30913092 queue : string ;
3093+ concurrencyKey ?: string ;
30923094 env : RunQueueKeyProducerEnvironment ;
30933095 } ) {
30943096 const messageId = runId ;
30953097 const messageKey = this . keys . messageKey ( orgId , messageId ) ;
3096- const queueCurrentConcurrencyKey = this . keys . queueCurrentConcurrencyKey ( env , queue ) ;
3098+ /**
3099+ * Callers pass the bare TaskRun queue name plus its concurrencyKey; the run's
3100+ * slots live on the ck variant, and the tracked clear additionally mirrors the
3101+ * group set and counters that only keyed queues maintain.
3102+ */
3103+ const fullQueue = concurrencyKey ? this . keys . queueKey ( env , queue , concurrencyKey ) : queue ;
3104+ const queueCurrentConcurrencyKey = this . keys . queueCurrentConcurrencyKey (
3105+ env ,
3106+ queue ,
3107+ concurrencyKey
3108+ ) ;
30973109 const envCurrentConcurrencyKey = this . keys . envCurrentConcurrencyKey ( env ) ;
3098- const queueCurrentDequeuedKey = this . keys . queueCurrentDequeuedKey ( env , queue ) ;
3110+ const queueCurrentDequeuedKey = this . keys . queueCurrentDequeuedKey ( env , queue , concurrencyKey ) ;
30993111 const envCurrentDequeuedKey = this . keys . envCurrentDequeuedKey ( env ) ;
31003112
31013113 this . logger . debug ( "Calling clearMessageFromConcurrencySets" , {
@@ -3110,15 +3122,15 @@ export class RunQueue {
31103122 service : this . name ,
31113123 } ) ;
31123124
3113- if ( queue . includes ( ":ck:" ) ) {
3125+ if ( fullQueue . includes ( ":ck:" ) ) {
31143126 return this . redis . clearMessageFromConcurrencySetsTracked (
31153127 queueCurrentConcurrencyKey ,
31163128 envCurrentConcurrencyKey ,
31173129 queueCurrentDequeuedKey ,
31183130 envCurrentDequeuedKey ,
3119- this . keys . queueRunningCounterKeyFromQueue ( queue ) ,
3120- this . keys . ckIndexKeyFromQueue ( queue ) ,
3121- this . keys . queueGroupConcurrencyKeyFromQueue ( queue ) ,
3131+ this . keys . queueRunningCounterKeyFromQueue ( fullQueue ) ,
3132+ this . keys . ckIndexKeyFromQueue ( fullQueue ) ,
3133+ this . keys . queueGroupConcurrencyKeyFromQueue ( fullQueue ) ,
31223134 messageKey ,
31233135 messageId ,
31243136 this . options . redis . keyPrefix ?? "" ,
@@ -4143,8 +4155,6 @@ if enableFastPath == '1' then
41434155 tonumber(redis.call('GET', queueConcurrencyLimitKey) or '1000000'),
41444156 envLimit
41454157 )
4146- if totalConcurrencyEnabled then
4147- end
41484158
41494159 if queueCurrent < queueLimit then
41504160 -- Total-cap gate: a fast-path admit consumes a group slot, so it must
@@ -4318,8 +4328,6 @@ if enableFastPath == '1' then
43184328 tonumber(redis.call('GET', queueConcurrencyLimitKey) or '1000000'),
43194329 envLimit
43204330 )
4321- if totalConcurrencyEnabled then
4322- end
43234331
43244332 if queueCurrent < queueLimit then
43254333 -- Total-cap gate: see enqueueMessageCkTracked.
@@ -4785,6 +4793,10 @@ else
47854793 redis.call('ZADD', masterQueueKey, earliestMessage[2], queueName)
47864794end
47874795
4796+ -- Re-sample the gauge so the emitted snapshot includes this batch's admissions;
4797+ -- the top-of-script sample only covers the early returns where nothing was admitted.
4798+ ${ QUEUE_METRICS_GAUGE_LUA }
4799+
47884800-- Return results as a flat array: [messageId1, messageScore1, messagePayload1, messageId2, messageScore2, messagePayload2, ...]
47894801return __qmret(results)
47904802 ` ,
0 commit comments