transaction fails with already rolled back if connection fails
See original GitHub issueSo I recently did a clean install of my node_modules
directory, and I guess something small upgraded automatically (semver and all that) that broke sequelize transactions entirely.
This is all I have to go on at the moment.
ERROR: Error: Transaction cannot be rolled back because it has been finished with state: rollback
at Transaction.rollback (example.com/node_modules/sequelize/lib/transaction.js:158:11)
at example.com/node_modules/sequelize/lib/sequelize.js:1216:23
From previous event:
at Promise.catch (example.com/node_modules/sequelize/lib/promise.js:21:17)
at transactionResolver (example.com/node_modules/sequelize/lib/sequelize.js:1211:15)
From previous event:
at Sequelize.transaction (example.com/node_modules/sequelize/lib/sequelize.js:1227:12)
at example.com/database/models/user/permissions/permission.js:35:19
at next (native)
at tryCatcher (example.com/node_modules/bluebird/js/release/util.js:11:23)
at PromiseSpawn._promiseFulfilled (example.com/node_modules/bluebird/js/release/generators.js:90:49)
at Promise._settlePromise (example.com/node_modules/bluebird/js/release/promise.js:550:26)
at Promise._settlePromise0 (example.com/node_modules/bluebird/js/release/promise.js:590:10)
at Promise._settlePromises (example.com/node_modules/bluebird/js/release/promise.js:673:18)
at Async._drainQueue (example.com/node_modules/bluebird/js/release/async.js:125:16)
at Async._drainQueues (example.com/node_modules/bluebird/js/release/async.js:135:10)
at Immediate.Async.drainQueues [as _onImmediate] (example.com/node_modules/bluebird/js/release/async.js:16:14)
at processImmediate [as _immediateCallback] (timers.js:383:17)
Where the code being executed in permission.js is a script to initialize permissions in the database. It uses a transaction.
I removed that transaction entirely, and it just failed with the same message on the next transaction in the code to be executed. Same after that. Any transaction I run produces that error now.
I have a sneaking suspicion it’s Babel that is messing it up, but I haven’t been able to determine it yet. I use sequelize.transaction(async (t) => {/*Use transaction*/})
in conjunction with the bluebird coroutines transformer on Babel 5, and it might be messing up that async function.
If you have any thoughts on what could lead to an error like that, please let me know. I can’t do any work until I fix this.
Issue Analytics
- State:
- Created 8 years ago
- Comments:6 (3 by maintainers)
Well, then. I fixed it. One thing I didn’t mention is that the first time I ran
npm install
after clearing out my modules, it used up so much RAM it crashed my VPS. Normally, PostgreSQL would start up when the server started, but it seems to have been stuck in limbo for some reason.A simple call to
sudo /etc/init.d/postgresql restart
and all my code works completely normally again.I’ll go ahead and close this, but perhaps some further investigation into how sequelize handles connection errors (or whatever error it was actually encountering) in conjunction with transactions might help.
Alright, thank you 😃