From d42f1ab7651ca4d373f411c1a97016170e01dc2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20Adel=C3=B6w?= Date: Tue, 19 May 2026 22:21:27 +0200 Subject: [PATCH] Skip wrapping in transaction when caller already provides one MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.6 (1M context) Signed-off-by: Fredrik Adelöw --- .../operations/stitcher/getDeferredStitchableEntities.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/plugins/catalog-backend/src/database/operations/stitcher/getDeferredStitchableEntities.ts b/plugins/catalog-backend/src/database/operations/stitcher/getDeferredStitchableEntities.ts index 0ceee1fb53..20c2d863eb 100644 --- a/plugins/catalog-backend/src/database/operations/stitcher/getDeferredStitchableEntities.ts +++ b/plugins/catalog-backend/src/database/operations/stitcher/getDeferredStitchableEntities.ts @@ -60,7 +60,7 @@ export async function getDeferredStitchableEntities(options: { // next_stitch_at has been bumped. Without the transaction the locks // are released after the SELECT auto-commits, and another worker can // claim the same rows before the UPDATE runs. - return knex.transaction(async tx => { + const run = async (tx: Knex | Knex.Transaction) => { let itemsQuery = tx('stitch_queue').select( 'entity_ref', 'next_stitch_at', @@ -94,7 +94,12 @@ export async function getDeferredStitchableEntities(options: { stitchTicket: i.stitch_ticket, stitchRequestedAt: timestampToDateTime(i.next_stitch_at), })); - }); + }; + + if (knex.isTransaction) { + return run(knex); + } + return knex.transaction(run); } function nowPlus(knex: Knex, duration: HumanDuration): Knex.Raw {