fix(lock): valid lock types and modernize locking providers#62421
Draft
joshtrichards wants to merge 3 commits into
Draft
fix(lock): valid lock types and modernize locking providers#62421joshtrichards wants to merge 3 commits into
joshtrichards wants to merge 3 commits into
Conversation
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>
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.
NOTE: #62374 is a dependency for this PR; review/merge that one first then rebase this one
Summary
DBLockingProvider.Details
Both providers now explicitly accept only
LOCK_SHAREDandLOCK_EXCLUSIVE. Previously, an invalid value passed toacquireLock()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
LockingProvidercontract tests cover shared/exclusive acquisition, release, conversion, andreleaseAll()behavior through both concrete providers.TODO
Checklist
3. to review, feature component)stable32)AI (if applicable)