[13.x] Only handle unique constraint violations when acquiring database locks#60269
Closed
Tresor-Kasenda wants to merge 1 commit into
Closed
[13.x] Only handle unique constraint violations when acquiring database locks#60269Tresor-Kasenda wants to merge 1 commit into
Tresor-Kasenda wants to merge 1 commit into
Conversation
…se locks ## Description This pull request updates `DatabaseLock::acquire()` so it only falls back to updating an existing lock when the insert fails due to a unique constraint violation. Previously, the method caught any `QueryException`, which could hide unrelated database errors such as missing tables, invalid SQL, permission issues, or connection problems. Those errors should be surfaced to the developer instead of being treated as a lock contention case. This PR also adds regression coverage for both paths: - non-unique insert query exceptions are rethrown - unique constraint violations still fall back to updating the existing lock Fixes laravel#60171. ## Tests ```bash php vendor/bin/phpunit tests/Integration/Database/DatabaseLockTest.php vendor/bin/pint --dirty --format=agent git diff --check
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This pull request updates
DatabaseLock::acquire()so it only falls back to updating an existing lock when the insert fails due to a unique constraint violation.Previously, the method caught any
QueryException, which could hide unrelated database errors such as missing tables, invalid SQL, permission issues, or connection problems. Those errors should be surfaced to the developer instead of being treated as a lock contention case.This PR also adds regression coverage for both paths:
Fixes #60171.