Skip to content

Commit b8c14e6

Browse files
committed
Fix for completing batches (when there are idempotent runs)
1 parent e837500 commit b8c14e6

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

apps/webapp/app/runEngine/services/batchTrigger.server.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -564,20 +564,27 @@ export class RunEngineBatchTriggerService extends WithRunEngine {
564564
runIds: {
565565
push: runIds,
566566
},
567+
processingJobsCount: {
568+
increment: runIds.length,
569+
},
570+
},
571+
select: {
572+
processingJobsCount: true,
573+
runCount: true,
567574
},
568575
});
569576

570-
// if there are more items to process, requeue the batch
571-
if (workingIndex < batch.runCount) {
572-
return { status: "INCOMPLETE", workingIndex };
573-
}
574-
575577
//triggered all the runs
576-
if (updatedBatch.runIds.length === updatedBatch.runCount) {
578+
if (updatedBatch.processingJobsCount >= updatedBatch.runCount) {
577579
//if all the runs were idempotent, it's possible the batch is already completed
578580
await this._engine.tryCompleteBatch({ batchId: batch.id });
579581
}
580582

583+
// if there are more items to process, requeue the batch
584+
if (workingIndex < batch.runCount) {
585+
return { status: "INCOMPLETE", workingIndex };
586+
}
587+
581588
return { status: "COMPLETE" };
582589
}
583590

0 commit comments

Comments
 (0)