Skip to content

packages/lock: negative timeout should wait forever, adapters treat it as no-wait #13719

Description

@loks0n

Utopia\Lock\Lock::acquire() documents its contract as: 0.0 means do not wait, a negative value means wait forever.

File::acquire() returns $this->tryAcquire() for every $timeout <= 0.0, so a negative timeout is a single non-blocking attempt. Under contention a caller following the documented contract gets an immediate false, or a Contention exception from withLock(), instead of waiting. The Redis Distributed adapter and the non-coroutine Mutex and Semaphore paths have the same shape.

Either the adapters honour negative as unbounded, or the interface doc drops the negative case; pick one and cover it with a unit test on the file lock (contention from a second process or a pre-held handle, negative timeout, assert it blocks until release).

Found by review on #13718 while absorbing the package; left out of that PR because absorption does not change library behaviour. The library now lives at packages/lock, so the fix lands here and releases with bin/monorepo release lock.

Activity

  1. self-assigned this
    on Sep 16, 2026
  2. added
    bug
    on Sep 16, 2026
  3. added
    product / databases
    product / storage
    product / vcs
    on Sep 16, 2026
  4. piyushthawale19 commented on Oct 2, 2026

    @piyushthawale19

    Hi! I'd like to work on this issue. Could you please assign it to me?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugproduct / databasesproduct / storageproduct / vcs

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions