Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Messenger] Swallow Exception on Rollback#54355

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
rodnaph wants to merge1 commit intosymfony:7.4
base:7.4
Choose a base branch
Loading
fromrodnaph:messenger-transaction-exception

Conversation

rodnaph
Copy link
Contributor

@rodnaphrodnaph commentedMar 20, 2024
edited
Loading

QA
Branch?7.1
Bug fix?no
New feature?no
Deprecations?no
IssuesNone
LicenseMIT

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.

if there is an exception rolling back the transaction then the originalexception will be hidden.
@rodnaphrodnaphforce-pushed themessenger-transaction-exception branch fromd468c1a tod0619baCompareMarch 20, 2024 15:57
@rodnaphrodnaph changed the title[Messenger] Only Rollback When Active Transaction[Messenger] Swallow Exception on RollbackMar 20, 2024
$entityManager->getConnection()->rollBack();
try {
$entityManager->getConnection()->rollBack();
} catch (\Throwable $e) {
Copy link
ContributorAuthor

@rodnaphrodnaphMar 20, 2024
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Suggested change
}catch (\Throwable$e) {
}catch (\Throwable$e) {
$exception =new \Exception($e->getMessage(),$e->getCode(),$exception);

Is it better to pass along some notification of rollback failure? This will interfere with the check a few lines below though, so would need to be structured differently.

@xabbuhxabbuh modified the milestones:7.1,7.2May 15, 2024
@rodnaph
Copy link
ContributorAuthor

Similar issue:doctrine/orm#7545

@fabpotfabpot modified the milestones:7.2,7.3Nov 20, 2024
@fabpotfabpot modified the milestones:7.3,7.4May 26, 2025
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Projects
None yet
Milestone
7.4
Development

Successfully merging this pull request may close these issues.

4 participants
@rodnaph@fabpot@xabbuh@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp