Skip to content

Commit 48e1e72

Browse files
authored
v4: fix stuck batch issue when processing happens before transaction commits (#2163)
* v4: fix stuck batch issue when processing happens before transaction commits * Fix flaky test
1 parent 3f2b748 commit 48e1e72

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

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

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -273,15 +273,18 @@ export class RunEngineBatchTriggerService extends WithRunEngine {
273273

274274
switch (this._batchProcessingStrategy) {
275275
case "sequential": {
276-
await this.#enqueueBatchTaskRun({
277-
batchId: batch.id,
278-
processingId: batchId,
279-
range: { start: 0, count: PROCESSING_BATCH_SIZE },
280-
attemptCount: 0,
281-
strategy: this._batchProcessingStrategy,
282-
parentRunId: body.parentRunId,
283-
resumeParentOnCompletion: body.resumeParentOnCompletion,
284-
});
276+
await this.#enqueueBatchTaskRun(
277+
{
278+
batchId: batch.id,
279+
processingId: batchId,
280+
range: { start: 0, count: PROCESSING_BATCH_SIZE },
281+
attemptCount: 0,
282+
strategy: this._batchProcessingStrategy,
283+
parentRunId: body.parentRunId,
284+
resumeParentOnCompletion: body.resumeParentOnCompletion,
285+
},
286+
tx
287+
);
285288

286289
break;
287290
}

apps/webapp/test/fairDequeuingStrategy.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,8 +263,8 @@ describe("FairDequeuingStrategy", () => {
263263

264264
console.log("Second distribution took", distribute2Duration, "ms");
265265

266-
// Make sure the second call is more than 9 times faster than the first
267-
expect(distribute2Duration).toBeLessThan(withTolerance(distribute1Duration / 9));
266+
// Make sure the second call is more than 2 times faster than the first
267+
expect(distribute2Duration).toBeLessThan(withTolerance(distribute1Duration / 2));
268268

269269
const startDistribute3 = performance.now();
270270

0 commit comments

Comments
 (0)