Skip to content

fix(lock): valid lock types and modernize locking providers#62421

Draft
joshtrichards wants to merge 3 commits into
masterfrom
jtr/cleanup-LockingProviders
Draft

fix(lock): valid lock types and modernize locking providers#62421
joshtrichards wants to merge 3 commits into
masterfrom
jtr/cleanup-LockingProviders

Conversation

@joshtrichards

Copy link
Copy Markdown
Member
  • Resolves: #

NOTE: #62374 is a dependency for this PR; review/merge that one first then rebase this one

Summary

  • Simplify and clarify shared-lock bookkeeping in DBLockingProvider.
  • Improve readability of database query construction and lock lifecycle comments.
  • Replace Memcache’s exclusive-lock magic value with a named constant.
  • Simplify Memcache TTL helper control flow and tidy the shared-lock TTL restoration behavior note.
  • Validate supported lock types before either provider reads or mutates its backing store (note: depends on refactor(lock): simplify acquired lock tracking #62374)

Details

Both providers now explicitly accept only LOCK_SHARED and LOCK_EXCLUSIVE. Previously, an invalid value passed to acquireLock() could follow the exclusive-acquisition path before request-local lock tracking occurred. The validation is performed before backend mutation, preventing an untracked lock from being created.

The DB provider retains its existing per-request shared-lock reuse behavior: a shared database lock may remain after it is released from active request bookkeeping and is cleaned up by releaseAll().

The Memcache provider retains its existing conditional TTL restoration logic. The cleanup makes the compare-and-set intent and the concurrent shared-lock failure mode easier to follow without changing its behavior.

Testing

  • Existing LockingProvider contract tests cover shared/exclusive acquisition, release, conversion, and releaseAll() behavior through both concrete providers.
  • Existing DB-specific tests cover cached shared-lock reuse and cleanup.
  • Added invalid lock-type coverage in the shared contract suite

TODO

Checklist

AI (if applicable)

  • The content of this PR was partly or fully generated using AI

Replace the magic exclusive-lock value with a named constant, simplify TTL handling, reject invalid lock types explicitly, clarify lock-release and conversion logic, and improve concurrency documentation around shared-lock TTL restoration.

Assisted-by: GitHubCopilot:GPT-5.6

Signed-off-by: Josh <josh.t.richards@gmail.com>
Clarify retained shared-lock bookkeeping, align query construction, reject invalid lock types explicitly, and remove redundant inherited documentation.

Assisted-by: GitHubCopilot:GPT-5.6

Signed-off-by: Josh <josh.t.richards@gmail.com>
Signed-off-by: Josh <josh.t.richards@gmail.com>
@joshtrichards joshtrichards added this to the Nextcloud 35 milestone Jul 22, 2026
@joshtrichards joshtrichards added 2. developing Work in progress technical debt 🧱 🤔🚀 feature: locking ♻️ refactor Refactor code (not a bug fix, not a feature just refactoring) labels Jul 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2. developing Work in progress AI assisted feature: locking ♻️ refactor Refactor code (not a bug fix, not a feature just refactoring) technical debt 🧱 🤔🚀

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants