-
Notifications
You must be signed in to change notification settings - Fork 11.2k
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
[5.1] beginTransaction(): Reconnect if connection is lost #15511
[5.1] beginTransaction(): Reconnect if connection is lost #15511
Conversation
If we're beginning a new transaction, we should check if the exception was caused by a lost connection. If so, then try again (like we do when when running a query/statement). We won't do a reconnect if it is a nested transaction though, because if the connection has been lost then the transaction has already been rolled back. (Queries/statements already won't try to reconnect if they're inside a transaction, either.)
We need another test please. |
I couldn't figure out how to write a test for this. Any tips? |
DIdn't we just revert something like this? |
Are you possibly referring to 0b94001? |
Yeah, that might be what is jogging my memory. |
I've added a couple tests. |
Ping @taylorotwell. So what do you think? 😄 |
I dont know it seems like there would be a better way to do this without changing so much code and logic. |
I don't follow. Could you elaborate? There is very little code and logic changed. The only real logic change is this bit here that checks if the exception was caused by a lost connection, if so it reconnects then tries to begin the transaction again.
Additionally, I moved the Excluding tests and PHPDoc fixes, this PR is really just 11 additions and 8 deletions. |
We've been having this issue on workers, they sometimes fail in I think this would solve our problems! |
I'll reopen it so I can take a fresh look. |
@taylorotwell Will this fix be implemented on L5.2? |
Unlikely. Only 5.1 is LTS, not 5.2. |
what's time to revised release version? I found that the lasted version of 5.1 not include this change! |
Is this related to #17785 ? |
I couldn't figure out how to get PHPUnit to do what I wanted in order to write a test for this. There doesn't seem to be a way to do
for the first run of
$this->getPdo()->beginTransaction()
but then expect a second run of$this->getPdo()->beginTransaction()
to run successfully.Let me know if you have any suggestions on how to test this.
This PR should, at least partly, fix issue #15179.