Limits of Knex.js Nested Transactions When Savepoints Are Unavailable
0 reputation · 01 Mar 2023, 21:37 UTC
Goal
Determine whether Knex.js should automatically emulate savepoints for databases that lack native savepoint support when a nested transaction is rolled back, or instead surface the limitation through an explicit error.
Constraints and Uncertainty
Knex.js currently issues a ROLLBACK TO SAVEPOINT on databases with savepoint capability (e.g., PostgreSQL, SQLite) and falls back to a full ROLLBACK on databases without it (e.g., MySQL InnoDB). This fallback can unintentionally discard work performed in the outer transaction, and the library’s design discussion remains unresolved on whether to provide application‑level savepoint emulation or to enforce an error.
- What is the current behavior of Knex.js’s transaction.js when it detects missing savepoint support?
- Is there a plan to introduce a configuration flag that enables savepoint emulation for unsupported databases?
- How should developers handle nested transactions on MySQL‑based projects to avoid unintended outer‑transaction rollbacks today?