Skip to content

Fix incorrect handling of transactions using deferred constraints #8

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from

Conversation

simPod
Copy link
Owner

@simPod simPod commented Oct 12, 2024

doctrine#6543 partially solved what we tried to achieve in doctrine#4846. With that There's no active transaction exception contains the actual exception in $previous.

Now, let's get rid of There's no active transaction exception which occurs e.g. when using deferred constraints so the violation is checked at the end of the transaction and not during it.

The current faulty flow is following:

  1. on commit(), Unique violation occurs
  2. transaction is implicitly aborted in database
  3. DBAL calls rollback()
  4. Since there's no active transaction, There's no active transaction exception is thrown:
image

This PR adjusts the flow so:

  1. on commit(), Unique violation occurs
  2. transaction is implicitly aborted in database
  3. DBAL DOES NOT call rollback() 🥳

@simPod simPod changed the title Run risky code in finally block Fix incorrect handling of transactions using deferred constraints Oct 12, 2024
@simPod simPod force-pushed the df-c_v3 branch 4 times, most recently from 71d9315 to 8406a57 Compare October 12, 2024 11:58
Let's get rid of There's no active transaction exception which occurs e.g. when using deferred constraints so the violation is checked at the end of the transaction and not during it.
@simPod simPod closed this Oct 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant