PHP 8: "PDOException: There is no active transaction" #11542
Unanswered
JarJak
asked this question in
Support Questions
Replies: 1 comment
-
First of all, it's PDO being picky about the transaction status. Postgres allows to rollback without an active transaction, but PDO throws. 🤷🏻♂️ If we want to file this as a bug, I need a reproducer for the issue. Otherwise, we can neither determine the cause of your problem nor find the right fix. Moving to support for the time being. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Bug Report
I am not sure if this is bug for ORM or DBAL.
Versions:
PHP 8.2
ORM 2.19.5
DBAL 3.8.6
Symfony 8.2
Postgres 13.7
DBAL config:
Summary
When using transactions inside code, when exception occurs "entitymanager is closed" and transaction is rollbacked, that results in "PDOException: There is no active transaction" error.
I have seen similar bugs reported, but they either happen with MySQL/MariaDB or in migrations. For me this happens with Postgres and in regular app code.
Even though before rollbacking, Doctrine checks if it has a flag for active transaction before sending
ROLLBACK
sql to the database, for some reason this does not always work.Code fragment from UoW commit() method (which is always called in flush() regardless of transaction mode): https://github.com/doctrine/orm/blob/3.2.x/src/UnitOfWork.php#L439
Proposed solution
One "dirty and hacky" way to fix it would be to add another try/catch inside the code above:
Or to do this try/catch inside
Connection->rollBack()
Beta Was this translation helpful? Give feedback.
All reactions