#6651·dbal

MySQL + deadlock leads to `SAVEPOINT DOCTRINE_x does not exist`

Author: nikophilCreated Dec 18, 2024Updated Jul 18, 2026
LabelsRequires Feedback

Bug Report

Q A
Version any

Summary

Hello,

this issue is a follow up of https://github.com/doctrine/orm/issues/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 https://github.com/doctrine/orm/pull/11646 - and this will soon be fixed as well in symfony/messenger.

Nevertheless, https://github.com/doctrine/orm/issues/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 :sweat_smile:

From MySQL doc:

When deadlock detection is enabled (the default) and a deadlock does occur, InnoDB detects the condition and rolls back one of the transactions (the victim).

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?