-
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
[4.2] Connection::run breaks transaction logic when connection lost inside transaction. #5937
Comments
Does Laravel emulate transactions by grouping SQLs or really use InnoDB transactions? |
Actually, the real mechanism depends on what connection is used (yupp, InnoDB or other transaction-safe engines transactoins for |
For example you have following SQLs:
then we lost connection on which
But I agree, that if SQL error happens during transaction SQL execution, then whole transaction should be aborted with an error. Reconnecting can't re-run previously executed SQLs in that transaction. |
if @GrahamCampbell or/and @taylorotwell (or/and others) confirm which of proposed ways is better or prose they own I will provide PR with tests in a few hours. This bug is damn critical for me and I spent a night finding out why my database looks like after 2n World War. P.S.: I stands for adding transaction level check > 0 to |
Further discussion can move to your pull - #5944. |
[4.2] Fix for #5937 Connection::run breaks transaction logic when connection lost inside transaction.
I've being looking for a way to catch query-related errors properly to fix bug with nested transactions support (the project I'm working on now) and I found that if we start transaction, then lost connection inside running transaction, whole transaction logic will be broken due to
Connection::reconnectIfMissingConnection
andConnection::tryAgainIfCausedByLostConnection
calls inConnection::run()
method:This bug looks for me quite critical while it silently may lead to broken data in database. Especially, keeping in mind that usually transaction are used in mission-critical places where data integrity required.
I propose to skip
Connection::reconnectIfMissingConnection
andConnection::tryAgainIfCausedByLostConnection
calls ifConnection::$transactions > 0
or modify them to throw exceptions and reset
Connection::$transactions
to0
when they called.The text was updated successfully, but these errors were encountered: