@@ -359,7 +359,7 @@ async function createWorkerQueue(
359359) {
360360 let queueName = sanitizeQueueName ( queue . name ) ;
361361
362- const concurrencyLimit =
362+ const baseConcurrencyLimit =
363363 typeof queue . concurrencyLimit === "number"
364364 ? Math . max (
365365 Math . min (
@@ -373,32 +373,34 @@ async function createWorkerQueue(
373373
374374 const taskQueue = await upsertWorkerQueueRecord (
375375 queueName ,
376- concurrencyLimit ?? null ,
376+ baseConcurrencyLimit ?? null ,
377377 orderableName ,
378378 queueType ,
379379 worker ,
380380 prisma
381381 ) ;
382382
383+ const newConcurrencyLimit = taskQueue . concurrencyLimit ;
384+
383385 if ( ! taskQueue . paused ) {
384- if ( typeof concurrencyLimit === "number" ) {
386+ if ( typeof newConcurrencyLimit === "number" ) {
385387 logger . debug ( "createWorkerQueue: updating concurrency limit" , {
386388 workerId : worker . id ,
387389 taskQueue,
388390 orgId : environment . organizationId ,
389391 projectId : environment . projectId ,
390392 environmentId : environment . id ,
391- concurrencyLimit,
393+ concurrencyLimit : newConcurrencyLimit ,
392394 } ) ;
393- await updateQueueConcurrencyLimits ( environment , taskQueue . name , concurrencyLimit ) ;
395+ await updateQueueConcurrencyLimits ( environment , taskQueue . name , newConcurrencyLimit ) ;
394396 } else {
395397 logger . debug ( "createWorkerQueue: removing concurrency limit" , {
396398 workerId : worker . id ,
397399 taskQueue,
398400 orgId : environment . organizationId ,
399401 projectId : environment . projectId ,
400402 environmentId : environment . id ,
401- concurrencyLimit,
403+ concurrencyLimit : newConcurrencyLimit ,
402404 } ) ;
403405 await removeQueueConcurrencyLimits ( environment , taskQueue . name ) ;
404406 }
@@ -455,6 +457,8 @@ async function upsertWorkerQueueRecord(
455457 } ,
456458 } ) ;
457459 } else {
460+ const hasOverride = taskQueue . concurrencyLimitOverriddenAt !== null ;
461+
458462 taskQueue = await prisma . taskQueue . update ( {
459463 where : {
460464 id : taskQueue . id ,
@@ -463,7 +467,9 @@ async function upsertWorkerQueueRecord(
463467 workers : { connect : { id : worker . id } } ,
464468 version : "V2" ,
465469 orderableName,
466- concurrencyLimit,
470+ // If overridden, keep current limit and update base; otherwise update limit normally
471+ concurrencyLimit : hasOverride ? undefined : concurrencyLimit ,
472+ concurrencyLimitBase : hasOverride ? concurrencyLimit : undefined ,
467473 } ,
468474 } ) ;
469475 }
0 commit comments