symfony icon indicating copy to clipboard operation
symfony copied to clipboard

[Messenger] Swallow Exception on Rollback

Open rodnaph opened this issue 2 years ago • 0 comments

Q A
Branch? 7.1
Bug fix? no
New feature? no
Deprecations? no
Issues None
License MIT

When a database level exception occurs, eg. constraint violations, it may not be possible to rollback the active transaction when handing the exception in the Messenger middleware. In this case an exception is thrown from rollback, and the original exception is lost.

I've added a try/catch to swallow any exception rolling back, so the original exception will be thrown as expected. I don't know if there is better behaviour here, just swallowing the exception seems quite poor. We could create a new exception with the rollback error, adding the original exception to it?

I also tried checking if there was an active transaction before rolling back, but that does not seem to be a reliable method for catching this condition.

I've marked this as neither a bugfix or a feature... it's a minor improvement, but let me know if I should update the description.

rodnaph avatar Mar 20 '24 15:03 rodnaph