question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

transaction fails with already rolled back if connection fails

See original GitHub issue

So 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:closed
  • Created 8 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
novacrazycommented, Nov 12, 2015

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.

0reactions
novacrazycommented, Nov 12, 2015

Alright, thank you 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

SQLite C interface: what happens if transaction rollback fails?
A previously committed and/or rolled-back transaction cannot be rolled back again, so it would cause an error. This would indicate some type of ......
Read more >
SqlTransaction.Rollback Method (System.Data.SqlClient)
A Rollback generates an InvalidOperationException if the connection is terminated or if the transaction has already been rolled back on the server. For...
Read more >
Transaction - SQLite
Transactions can be started manually using the BEGIN command. Such transactions usually persist until the next COMMIT or ROLLBACK command. But a ...
Read more >
Does a database transaction rollback if a PHP/Gateway ...
A transaction is only rolled back when Transaction::rollBack() is explicitly called. In case of time outs, that doesn't happen.
Read more >
Error Messages - SQLAlchemy 1.4 Documentation
Can't reconnect until invalid transaction is rolled back¶. This error condition refers to the case where a Connection was invalidated, either due to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found