Skip to content
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

[6.x] Reconnect missing connection when beginning transaction #30474


Copy link

cmorbitzer commented Oct 31, 2019

This PR adds a check that a connection is not missing before beginning a transaction, and reconnects if it is. This is the same check added in 143f7a9 that is performed before running a query in Illuminate\Database\Connection::run().

I ran into this while running a Laravel Excel queued import on Vapor. Vapor disconnects all database connections at the end of each queued job execution in QueueHandler::terminate(). When the worker executes the next job, app('db.connection')->getPdo() returns null unless the connection is re-established, which currently only happens when running a query. So when the ReadChunk queued job in Laravel Excel attempts to begin a transaction before running a query here, $this->getPdo()->beginTransaction() in ManagesTransactions results in the error Call to a member function beginTransaction() on null.

@taylorotwell taylorotwell merged commit 742ff2d into laravel:6.x Oct 31, 2019
2 checks passed
2 checks passed
continuous-integration/styleci/pr The analysis has passed
continuous-integration/travis-ci/pr The Travis CI build passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
2 participants
You can’t perform that action at this time.