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

Merged
merged 1 commit into from
Oct 31, 2019
Merged

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

merged 1 commit into from
Oct 31, 2019

Conversation

cmorbitzer
Copy link
Contributor

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
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.

2 participants