Skip transaction wrapping when locking is not used
Only wrap the SELECT+UPDATE in a transaction for MySQL/PostgreSQL where FOR UPDATE SKIP LOCKED is actually used. For sqlite3 the transaction adds unnecessary BEGIN/COMMIT overhead. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Fredrik Adelöw <freben@gmail.com>
This commit is contained in:
@@ -263,9 +263,10 @@ export class DefaultProcessingDatabase implements ProcessingDatabase {
|
||||
return items;
|
||||
};
|
||||
|
||||
const items = knex.isTransaction
|
||||
? await run(knex)
|
||||
: await knex.transaction(run);
|
||||
const items =
|
||||
knex.isTransaction || !useLocking
|
||||
? await run(knex)
|
||||
: await knex.transaction(run);
|
||||
|
||||
return {
|
||||
items: items.map(
|
||||
|
||||
+1
-1
@@ -92,7 +92,7 @@ export async function getDeferredStitchableEntities(options: {
|
||||
}));
|
||||
};
|
||||
|
||||
if (knex.isTransaction) {
|
||||
if (knex.isTransaction || !useLocking) {
|
||||
return run(knex);
|
||||
}
|
||||
return knex.transaction(run);
|
||||
|
||||
Reference in New Issue
Block a user