-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Convert driver exceptions when starting transactions #6812
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
Convert driver exceptions when starting transactions #6812
Conversation
Let's get it integration-tested. Even though the unit test passes, and the code works as expected on MySQL, we want to be sure that it works the same on other platforms as well or at least know that it doesn't. |
5fa77a9
to
5c1255f
Compare
6e47746
to
432b89d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code change and the tests look good. Thanks for replacing sleep()
with killing the session. Just a few nits inline.
This optimises how this test is executed by leveraging two connections and killing the one executing the tests. It also aims at making the whole conversion process available to other platforms. Signed-off-by: Luís Cobucci <[email protected]>
For long-running processes, it's possible that the wrapped connection is no longer valid and starting a transaction will lead to driver exceptions. DBAL Connection wasn't converting these, leaking internal details of the platform and not providing a consistent API (all other methods would throw a `ConnectionLost` exception for the scenario above). This ensures we do have the expected behaviour for this edge-case. Signed-off-by: Luís Cobucci <[email protected]>
This extends the functional test for connection loss detection to verify the behaviour against Postgres and ensures the ExceptionConverter for that API behaves as expected. Signed-off-by: Luís Cobucci <[email protected]>
This is required because the MySQLi API only returns a boolean result that we were simply not using. Signed-off-by: Luís Cobucci <[email protected]>
432b89d
to
b6eb520
Compare
Thanks, @lcobucci! |
I'm fine with releasing it any time. |
It would be great to have it released, then |
doctrine/dbal#6812 introduced a behavioral change on lost connection. Now all drivers behave the same, and close the connection explicitly before throwing.
Summary
The wrapped connection may no longer be valid for long-running processes, and starting a transaction will cause driver exceptions.
DBAL Connection wasn't converting these, leaking internal details of the platform and not providing a consistent API (all other methods would throw a
ConnectionLost
exception for the scenario above).This ensures we do have the expected behaviour for this edge case.