Transaction commit failing to insert data
See original GitHub issueI am using transactions, all appears to succeed, but 90% of the time no data is committed to the table.
Within the transaction I am executing the following code:
Users.find({ activationCode : activationCode }, {transaction: transaction})
Users.create(objectToCreate, {transaction: transaction})
I am seeing the following in the logs:
Executing (d5316d08-d28a-4b12-94a4-026b80821f12): START TRANSACTION;
Executing (d5316d08-d28a-4b12-94a4-026b80821f12): SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
Executing (d5316d08-d28a-4b12-94a4-026b80821f12): SET autocommit = 1;
Executing (default): SELECT * FROM "Users" WHERE "Users"."primaryEmailAddress"='test@mailhop.co.uk' LIMIT 1;
Executing (d5316d08-d28a-4b12-94a4-026b80821f12): INSERT INTO "Users" ("firstRun","active","createdAt","updatedAt","name","primaryEmailAddress","password","activationCode","resetPasswordCode") VALUES (true,false,'2014-02-19 06:03:20.702 +00:00','2014-02-19 06:03:20.704 +00:00','Test','test@mailhop.co.uk','sha1$572c4253$1$bbe0bb48e9e114daf48b7ada5a34c5cfed8f9250','5acc02b1-4799-4ed8-a58d-1f62ef54d119',NULL) RETURNING *;
Executing (d5316d08-d28a-4b12-94a4-026b80821f12): COMMIT;
I can’t see any reason, but I notice the find isn’t using the transaction. I am not sure if that is significant or note.
Any help would be much appreciated.
Issue Analytics
- State:
- Created 10 years ago
- Comments:54 (36 by maintainers)
Top Results From Across the Web
Handling transaction commit failures - EF6 - Microsoft Learn
Option 1 - Do nothing. The likelihood of a connection failure during transaction commit is low so it may be acceptable for your...
Read more >Ensure MySQL transaction fails on COMMIT - Stack Overflow
You executed several inserts and before your commit your database server dies. A transaction may fail if it doesn't receive commit .
Read more >Can we commit the transaction when the sql server trigger fails?
Even if the trigger fails, I want the data to be inserted in the Customers table, and the stored procedure should return the...
Read more >can't commit transaction - webMethods
but i found out the transaction don't work. it call public.art.transaction:rollbackTransaction to roll back the transaction after insert by ...
Read more >error: cannot commit (when inserting the row) — oracle-tech
Commits should be done outside and after the trigger has completed. If there is any reason to write to a table and commit...
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
Thanks for the help. The ideal solution, for me, would be to ignore the transaction completely. For example:
Then on “sequelize.startTransaction()”, if you used continuation-local-storage (https://www.npmjs.org/package/continuation-local-storage) you could save the transaction. For example:
You would need to initialize the namespace once when Sequelize starts:
Then when I call an operation (e.g.
Users.find({ activationCode : activationCode })
), you then pull the transaction and set it appropriately:As a developer all I am concerned about is demarcing the transaction boundary. I don’t need to care about how it is propagated and passed in to each function call.
@sdepold thanks for taking a look. I get the following error and a rollback (I need to scroll a way up to see the error):