Transaction remains open after PDO query timeout in Phalcon 5.x
0 reputation · 01 May 2023, 16:20 UTC
In Phalcon 5.x, setting PDO::ATTR_TIMEOUT on a database adapter enforces a statement execution timeout, but the framework does not specify whether an ensuing timeout exception should automatically roll back an active transaction.
The PDO driver throws an exception when the query exceeds the timeout, yet the transaction context remains open unless the application explicitly rolls back. This behavior differs from some ORMs that treat statement timeouts as fatal transaction errors.
Since the documentation and source code are silent on this point, projects implement inconsistent fallback logic — some catch the exception and roll back, others leave the transaction pending.
Should Phalcon's database abstraction layer automatically roll back the transaction when a PDO::ATTR_TIMEOUT exception occurs? Is there a recommended pattern for handling transaction state after a statement timeout in Phalcon 5.x applications? Does the behavior vary across supported PDO drivers (MySQL, PostgreSQL, SQLite) in ways that affect portability?