Does rollback really work?
See original GitHub issueKnex version: 0.16.3 Database + version: mysql, 5.5 OS: Windows
I am making the inner query fail by adding a wrong column! Inner query fails, but does not rollback whole transaction! Here is my code:
return knex.transaction(function (trx) {
return trx.insert({...}, 'id').into('dept').then(function (response) { **// passes, but should rollback!**
return trx.batchInsert('emp', [{...}, {...}], 10); **// wrong query!**
}).then(function (value) {
console.log('Inside success:', value);
// trx.commit();
}).catch(function (error) {
console.log('Inside error:', error); **// comes here!**
// trx.rollback(error);
throw new Error('Rolling back!');
});
}).catch((err) => {
console.log("We get here", err); **// comes here!; still no rollback??**
});
I tried with trx.rollback(); trx.rollback(error) or even throwing Error; with promise return and without promise return. It falls in both error blocks (inner and outer); still surprisingly no rollback!!
Issue Analytics
- State:
- Created 5 years ago
- Comments:25 (12 by maintainers)
Top Results From Across the Web
Does rollback really work? · Issue #3017 · knex/knex - GitHub
I am making the inner query fail by adding a wrong column! Inner query fails, but does not rollback whole transaction! Here is...
Read more >How We Rollback Code Releases In Less Than a Minute
Rollbacks required roughly the same amount of time to complete as a typical deploy (20m). That meant that a bad code release would...
Read more >Explaining netcode in games, and why rollback is overrated ...
Rollback is excellent for casual play but has significant vulnerabilities in competitive for-money play ; it's not a silver bullet, nor is it...
Read more >Rollback Netcode Explained - Game Rant
The idea is that rollback makes it so playing the game feels instant regardless of your opponent's connection. At the very least, a...
Read more >The art of rollback: What is rollback and how does it work?
I will not wait for the last episode to unveil the conclusion of the series: yes, it is possible to design a good...
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
I ran into transaction issues with knex and a legacy MySQL db, which led me to this thread. Cause of the issue was MyISAM was being used instead of InnoDB, so ensure you’re using the latter.
Cannot reproduce, add complete reproduction code please… something that creates necessary tables and shows that the code above does not work. Check CONTRIBUTING.md why and what minimal reproduction code means.