Skip to content

[13.x] Don't swallow deadlocks in DatabaseLock inside a transaction - #61708

Merged
taylorotwell merged 2 commits into
laravel:13.xfrom
lazerg:fix/database-lock-deadlock
Sep 24, 2026
Merged

taylorotwell merged 2 commits into
laravel:13.xfrom
lazerg:fix/database-lock-deadlock

Conversation

@lazerg

@lazerg lazerg commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

When the lock row insert hits a deadlock, acquire() catches it like any other insert failure and falls through to the update. If the lock shares a connection with an open transaction, MySQL has already rolled that transaction back. Laravel still thinks it's open, so the app keeps running with its earlier writes gone and later writes autocommitting.

This rethrows concurrency errors from the insert when the connection is inside a transaction, so DB::transaction() can roll back or retry like it does for any other deadlock. The prune and release queries only ignore concurrency errors outside a transaction now too, since they would leave the same broken state. Outside a transaction nothing changes.

Fixes #61707

@lazerg

lazerg commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor Author

Failing tests are not my fault..

@lazerg lazerg changed the title [13.x] Don't swallow deadlocks in DatabaseLock::acquire() inside a transaction [13.x] Don't swallow deadlocks in DatabaseLock inside a transaction Sep 24, 2026
@taylorotwell
taylorotwell merged commit 494a9c2 into laravel:13.x Sep 24, 2026
26 of 60 checks passed
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.

Database cache lock bug: SAVEPOINT trans2 does not exist

2 participants