-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
MySQL + deadlock leads to SAVEPOINT DOCTRINE_x does not exist
#6651
Comments
I am not sure how related this issue is; but I experience the following. I get the same error related to the I am using symfony with doctrine. I have a symfony command that prepares the application. My installation command is pretty simple. I run:
If I put If I run the command twice, there is no error due to the fact that the migrations are already executed and up to date. Even if I add multiple new entities, persist and flush them there are no issues if I run the migrations first. This issue only occurs after I updated from I have create an repo to reproduce this issue: https://github.com/petermanders89/dbal-issue. This is repo created with When running the install command; in this case with |
hey @petermanders89 if using MySQL, you should try to declare your migrations as "non transactional". In MySQL, "ALTER TABLE" statements, and all other statements which modify the db structure implicitly closes the transaction. At the end, when doctrine commits the changes, it tries to commit a non-existent transaction, and your migration fails 💥 |
Hey @nikophil . Thank you! That indeed solves all my issues related to this. Sorry to mess up your issue. |
@nikophil please provide a sample script or other instructions that will reproduce your issue. Ideally, it should use only DBAL as a dependency. |
Hi @morozov here it is: https://github.com/nikophil/dbal-repro you can run it by:
I've somehow reproduced a concurrency problem by running twice The concurrency creates a deadlock. On my machine, I have a deadlock, and an error on rollback every time I'm running the script. The script outputs the error, basically:
as you can see, the rollback throws an error, and the problem occurs for both dbal 3 et 4 |
Bug Report
Summary
Hello,
this issue is a follow up of doctrine/orm#11230: in MySQL, when a deadlock occurs because of concurrency, the system tries to rollback, and then an error "SAVEPOINT DOCTRINE_x does not exist" occurs.
At first, the savepoint error did hide the original deadlock error. This has been fixed thanks to doctrine/orm#11646 - and this will soon be fixed as well in symfony/messenger.
Nevertheless, doctrine/orm#11230 has been closed, but the original problem is not fixed, and the rollback still fails, which results in closing the EM, and breaking the worker.
Since the dbal is the only one aware of savepoints, I think this should be fixed here.
Current behavior
When a deadlock occur, within a transaction with savepoints in MySQL, the rollback fails with
SAVEPOINT DOCTRINE_x does not exist
Expected behavior
No error on roll back 😅
From MySQL doc:
So maybe when a deadlock occurs, DBAL should be resilient when the rollback fails? Or it should check the existence of the given savepoint/transaction before rolling back?
The text was updated successfully, but these errors were encountered: