Skip to content

Conversation

@cosmastech
Copy link
Contributor

@cosmastech cosmastech commented Dec 17, 2025

As my colleague pointed out here, the database lock prune lottery can be an expensive footgun. The fact that it is non-deterministic means that extra queries are executed which, without Chris' index, may cause a request or queued job to choke.

In this PR, I have added an easy way to opt out of the lottery execution by allowing null to be passed. This shouldn't break any existing implementation, as it requires specifying the lottery parameter as null. Prior to this, in order to opt out of the lottery, you had to pass something like [-1, 1]. This isn't obvious or clear.

In our codebase, I'm writing a console command that prunes DB locks, which we will schedule to run every minute. If that's helpful, I can add the console command here as well.

@taylorotwell taylorotwell merged commit a423678 into laravel:12.x Dec 17, 2025
70 checks passed
@cosmastech cosmastech deleted the patch-34 branch December 17, 2025 14:52
@rforced
Copy link

rforced commented Dec 17, 2025

@cosmastech Thank you for adding this! Is there any chance you'd be willing to add this to the docs as well?

iam-subho pushed a commit to iam-subho/laravel-core that referenced this pull request Dec 18, 2025
…el#58152)

* easy no lottery

* move pruning to separate method
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.

3 participants