Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.8] Locks acquired with block() are not immediately released if the callback fails #27957

Merged
merged 4 commits into from
Mar 21, 2019

Conversation

howey-aus
Copy link
Contributor

Currently, after block() successfully acquires a lock, tap() releases the lock only if $callback() is a success. However this won't happen if $callback fails in some way; the lock will only release when it was set to expire since there is nothing ensuring it on $callback's failure.

Contrast this with the behavior of get() which wraps $callback in a try/finally, so the lock is released immediately regardless of the outcome of the callback. This PR ensures block() exhibits the same behavior after successful lock acquisition.

Added redis integration test for this case.

…y if the callback passed to block() threw an exception, the lock would only be released when it expired.

Add integration test.
tests/Integration/Cache/RedisCacheLockTest.php Outdated Show resolved Hide resolved
@driesvints driesvints dismissed their stale review March 21, 2019 14:40

Changes were made

@taylorotwell taylorotwell merged commit e5164f8 into laravel:5.8 Mar 21, 2019
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