Skip to content

Clear transaction manager state on disconnect - #60574

Merged
taylorotwell merged 1 commit into
laravel:13.xfrom
lazerg:fix/disconnect-clears-transaction-manager
Jun 23, 2026
Merged

taylorotwell merged 1 commit into
laravel:13.xfrom
lazerg:fix/disconnect-clears-transaction-manager

Conversation

@lazerg

@lazerg lazerg commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

When a database connection is disconnected, any pending or committed transactions tracked by DatabaseTransactionsManager are not cleared. On serverless runtimes like Laravel Vapor, a warm Lambda reuse the same connection object across invocations, so afterCommit callbacks staged in committedTransactions from a previous invocation can fire during the next one's commit.

Connection::disconnect() now calls $this->transactionsManager?->rollback($this->getName(), 0) before resetting the PDO, which delegates to the existing removeAllTransactionsForConnection() path that already handles clearing pending transactions, committed transactions, and rollback callbacks.

Closes #60528

@taylorotwell
taylorotwell merged commit b5b0d6b into laravel:13.x Jun 23, 2026
55 checks passed
@lazerg
lazerg deleted the fix/disconnect-clears-transaction-manager branch June 23, 2026 18:47
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.

Stale callbacks in DatabaseTransactionsManager leaky into warm invocations when using Vapor

2 participants