New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Transaction finished
race condition
#5222
Comments
Moving to before the call seems the best course of action. |
Tried to move the Moving the assignment after the rollback transaction call in |
…e-condition Fix #5222: prevent race condition after transaction finished
There is logic in a transaction that basically flags a transaction as
finished
, which is then checked against when querying against that transaction. However, there is a race condition as both.rollback
and.commit
don't set this flag until after the "ROLLBACK" and "COMMIT" queries have succeeded.See https://github.com/sequelize/sequelize/blob/master/lib/transaction.js#L209 that the flag is set in the
finally
See the guard at
sequelize/lib/sequelize.js
Line 777 in 2a168da
Basically something like below is happening:
The below code will reproduce
Observe something like
The update goes out even though the transaction was just rolled back.
I believe the fix would be to just set the
finished
flag right after sending the ROLLBACK out, rather than in the .finally.Minor overall, as easily avoided by just making sure all your parallel requests are done before running the rollback.
The text was updated successfully, but these errors were encountered: