Skip to content

Conversation

@jackbayliss
Copy link
Contributor

@jackbayliss jackbayliss commented Dec 10, 2025

Since #57966

The addition of the index has caused the below in various environments for me quite often, which I believe is down to using WithoutOverlapping middleware in high throughput queues:

SQLSTATE[40001]: Serialization failure: 1213 Deadlock found when trying to get lock; try restarting transaction (Connection: mysql, SQL: delete from `cache_locks` where `expiration` <= 1765344745)

The index seems to improve query performance, but changes the order it gets row locks - hence why this happens.

Since the cleanup is opportunistic (cause its using a lottery) this PR uses the existing ConcurrencyErrorDetector to identify and ignore concurrency failures, while continuing to throw any other errors.

I've also added a test - which I think covers it - Any feedback or adjustments let me know 🫡

@github-actions
Copy link

Thanks for submitting a PR!

Note that draft PR's are not reviewed. If you would like a review, please mark your pull request as ready for review in the GitHub user interface.

Pull requests that are abandoned in draft may be closed due to inactivity.

@jackbayliss jackbayliss changed the title [12.x] Fix deadlock in database cache lock cleanup [12.x] Fix deadlock in database cache_locks on cleanup Dec 10, 2025
@jackbayliss jackbayliss changed the title [12.x] Fix deadlock in database cache_locks on cleanup [12.x] Fix deadlock in cache_locks on cleanup Dec 10, 2025
@jackbayliss jackbayliss marked this pull request as ready for review December 10, 2025 11:57
@taylorotwell taylorotwell merged commit a74e575 into laravel:12.x Dec 10, 2025
70 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.

2 participants