Skip to content

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

Merged
taylorotwell merged 1 commit into
laravel:6.xfrom
cmorbitzer:fix/transaction-reconnects-missing-connection
Oct 31, 2019
Merged

taylorotwell merged 1 commit into
laravel:6.xfrom
cmorbitzer:fix/transaction-reconnects-missing-connection

Conversation

@cmorbitzer

Copy link
Copy Markdown
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
salmanarshad321 pushed a commit to salmanarshad321/framework that referenced this pull request Sep 23, 2026
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