Repository navigation
fix(lock): honor negative acquire timeout as wait-forever - #13756
Merged
HarshMN2345 merged 12 commits intoOct 15, 2026
Merged
HarshMN2345 merged 12 commits into
HarshMN2345 merged 12 commits into
Conversation
Contributor
|
Contributor
Author
|
Friendly ping on this PR. Glad to make changes if anything needs adjusting. |
HarshMN2345
merged commit Oct 15, 2026
12150a1
into
appwrite:fix-lock-negative-timeout
1 check passed
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.
What does this PR do?
Utopia\Lock\Lock::acquire()documents its contract as:0.0means do not wait, a negative value means wait forever.File::acquire(),Distributed::acquire(), and the non-coroutineMutex/Semaphorepaths all treated every$timeout <= 0.0as a single non-blocking attempt, so under contention a caller following the documented contract got an immediatefalse(or aContentionfromwithLock()) instead of waiting.Each path now only short-circuits on exactly
0.0and retries without a deadline when the timeout is negative. Coroutine paths are untouched (Channel::push()already waits indefinitely on a negative timeout). Zero and positive timeout behavior is unchanged, including the jittered backoff inDistributed.Test Plan
Added
FileTest::testNegativeTimeoutWaitsUntilRelease, which forks a child process that holds the lock and asserts the parent'sacquire(-1.0)blocks until the child releases. It fails against the previous implementation and passes with this change.phpunit tests/FileTest.phpon PHP 8.3: OK (5 tests, 16 assertions)php -lclean on all package filesphpstanat the package's level 9 settings: no new findingsThe Swoole-backed Mutex/Semaphore tests and the Redis-backed E2E tier need
ext-swooleand a Redis server, so those run in CI.Related PRs and Issues
Checklist