From 2687fecffa84bc3aeba5162b6a9f118b7ff285e5 Mon Sep 17 00:00:00 2001 From: paula-alves Date: Wed, 4 Nov 2026 15:04:22 +0000 Subject: [PATCH] fix(library): give events patch's transaction room to acquire a connection (BIT-32057) Same error family as BIT-31703: Prisma's default maxWait is 2s, so under brief pool contention PATCH /v1/events/:eventId's $transaction could fail to even start with 'Unable to start a transaction in the given time', despite the trivial transaction body itself finishing well within the default 5s timeout. Set maxWait/timeout to 10s to match the headroom already used elsewhere (rebuildDirectory, assignGalleries) for this error family. --- apps/api/src/library/events.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/api/src/library/events.ts b/apps/api/src/library/events.ts index 0f60c01..e82d2f0 100644 --- a/apps/api/src/library/events.ts +++ b/apps/api/src/library/events.ts @@ -215,6 +215,8 @@ export async function registerEventRoutes(app: FastifyInstance, deps: { db: Db; startsAt || ingestFrom || ingestUntil ? ingestWindow(startsAt ?? current.startsAt, ingestFrom ?? (startsAt ? undefined : current.ingestFrom), ingestUntil ?? (startsAt ? undefined : current.ingestUntil)) : {}; + // Default maxWait (2000ms) was too tight under brief pool contention (BIT-32057); give this a bit more + // room to acquire a connection, same pattern as ArchiveService.rebuildDirectory (BIT-31703). const event = await db.$transaction(async (tx) => { if (photographerIds) { await tx.eventAssignment.deleteMany({ where: { eventId } }); @@ -233,7 +235,7 @@ export async function registerEventRoutes(app: FastifyInstance, deps: { db: Db; }, include, }); - }); + }, { maxWait: 10_000, timeout: 10_000 }); const teamsChanged = (match.homeTeamId !== undefined && match.homeTeamId !== current.homeTeamId) || (match.awayTeamId !== undefined && match.awayTeamId !== current.awayTeamId); if (teamsChanged && (event.homeTeamId || event.awayTeamId)) syncSquads(event.id); // New times, new photographers or back from the archive: photos waiting in "Sem evento" may now belong here. -- 2.47.3