Using nested transactions with save points
See original GitHub issueEnvironment
Knex version: 0.19.1
Database + version: PostgreSQL 11
OS: MacOS Mojave
Bug
I am trying to use nested transactions with save points and it doesn’t seems to be working with promises API.
Here’s some code (I am sharing the minimum required code to reproduce the problem)
Following doesn’t work
async function run () {
const trx = await knex.transaction()
const trx2 = await trx.transaction()
console.log('never reached here')
}
Following works
function runWithCallbacks () {
knex.transaction((trx) => {
trx.transaction((trx2) => {
console.log('reached here>')
})
})
}
The first example doesn’t work since the promise doesn’t resolve unless trx2
commit/rollback and it cannot, since the code never moves to the next line.
Is this the intended behavior?
Issue Analytics
- State:
- Created 4 years ago
- Comments:14 (9 by maintainers)
Top Results From Across the Web
Nested Transactions in SQL Server - Dot Net Tutorials
The SAVE TRANSACTION in SQL Server is used for dividing (or) breaking a transaction into multiple units so that the user has a...
Read more >Savepoint | Transactions | Ebean
Ebean supports using Savepoints which are a feature of most Relational Databases in which we can create a Savepoint (nested transaction) inside a ......
Read more >Use savepoints for nested transactions [#669794] | Drupal.org
Basically, we would create a new named savepoint with each nested "transaction." On each nested "commit," we tell the DB to retire the...
Read more >Savepoints - SQLite
SAVEPOINTs are a method of creating transactions, similar to BEGIN ... that the SAVEPOINT and RELEASE commands are named and may be nested....
Read more >SAVEPOINT | CockroachDB Docs
Transactions can be nested using named savepoints. RELEASE SAVEPOINT and ROLLBACK TO SAVEPOINT can both refer to a savepoint "higher" in the nesting...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@thetutlage Released in 0.19.2
Found one regression here. Now, since we are faking the container, the rejection behavior of rollback is to always reject.
As a solution, I believe we can set
doNotRejectOnRollback
when it’s not explicitly defined when starting a nested transaction.