@@ -58,7 +58,10 @@ export class RunEngineBatchTriggerService extends WithRunEngine {
5858 ) {
5959 super ( { prisma } ) ;
6060
61- this . _batchProcessingStrategy = batchProcessingStrategy ?? "parallel" ;
61+ // Eric note: We need to force sequential processing because when doing parallel, we end up with high-contention on the parent run lock
62+ // becuase we are triggering a lot of runs at once, and each one is trying to lock the parent run.
63+ // by forcing sequential, we are only ever locking the parent run for a single run at a time.
64+ this . _batchProcessingStrategy = "sequential" ;
6265 }
6366
6467 public async call (
@@ -316,6 +319,14 @@ export class RunEngineBatchTriggerService extends WithRunEngine {
316319 }
317320 }
318321
322+ async #enqueueBatchTaskRun( options : BatchProcessingOptions , tx ?: PrismaClientOrTransaction ) {
323+ await workerQueue . enqueue ( "runengine.processBatchTaskRun" , options , {
324+ tx,
325+ jobKey : `RunEngineBatchTriggerService.process:${ options . batchId } :${ options . processingId } ` ,
326+ } ) ;
327+ }
328+
329+ // This is the function that the worker will call
319330 async processBatchTaskRun ( options : BatchProcessingOptions ) {
320331 logger . debug ( "[RunEngineBatchTrigger][processBatchTaskRun] Processing batch" , {
321332 options,
@@ -648,13 +659,6 @@ export class RunEngineBatchTriggerService extends WithRunEngine {
648659 : undefined ;
649660 }
650661
651- async #enqueueBatchTaskRun( options : BatchProcessingOptions , tx ?: PrismaClientOrTransaction ) {
652- await workerQueue . enqueue ( "runengine.processBatchTaskRun" , options , {
653- tx,
654- jobKey : `RunEngineBatchTriggerService.process:${ options . batchId } :${ options . processingId } ` ,
655- } ) ;
656- }
657-
658662 async #handlePayloadPacket(
659663 payload : any ,
660664 pathPrefix : string ,
0 commit comments