Skip to content

Commit eff7ba8

Browse files
committed
Fix infinite v3.processBatchTaskRun enqueuings by checking the attemptCount
1 parent 2ecf510 commit eff7ba8

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

apps/webapp/app/v3/services/batchTriggerV2.server.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import { z } from "zod";
2525

2626
const PROCESSING_BATCH_SIZE = 50;
2727
const ASYNC_BATCH_PROCESS_SIZE_THRESHOLD = 20;
28+
const MAX_ATTEMPTS = 10;
2829

2930
export const BatchProcessingStrategy = z.enum(["sequential", "parallel"]);
3031
export type BatchProcessingStrategy = z.infer<typeof BatchProcessingStrategy>;
@@ -547,6 +548,16 @@ export class BatchTriggerV2Service extends BaseService {
547548

548549
const $attemptCount = options.attemptCount + 1;
549550

551+
// Add early return if max attempts reached
552+
if ($attemptCount > MAX_ATTEMPTS) {
553+
logger.error("[BatchTriggerV2][processBatchTaskRun] Max attempts reached", {
554+
options,
555+
attemptCount: $attemptCount,
556+
});
557+
// You might want to update the batch status to failed here
558+
return;
559+
}
560+
550561
const batch = await this._prisma.batchTaskRun.findFirst({
551562
where: { id: options.batchId },
552563
include: {

docker/docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ services:
6161
- 6379:6379
6262

6363
electric:
64-
image: electricsql/electric:0.8.1
64+
image: electricsql/electric:0.9.4
6565
restart: always
6666
environment:
6767
DATABASE_URL: postgresql://postgres:postgres@database:5432/postgres?sslmode=disable

internal-packages/testcontainers/src/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export async function createElectricContainer(
5555
network.getName()
5656
)}:5432/${postgresContainer.getDatabase()}?sslmode=disable`;
5757

58-
const container = await new GenericContainer("electricsql/electric:0.8.1")
58+
const container = await new GenericContainer("electricsql/electric:0.9.4")
5959
.withExposedPorts(3000)
6060
.withNetwork(network)
6161
.withEnvironment({

0 commit comments

Comments
 (0)