concurrency: stale Mutex.Unlock retry can delete a newer same-session lock - #22115
concurrency: stale Mutex.Unlock retry can delete a newer same-session lock#22115AkashKumar7902 wants to merge 1 commit into
Conversation
… lock Signed-off-by: Akash Kumar <meakash7902@gmail.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: AkashKumar7902 The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Hi @AkashKumar7902. Thanks for your PR. I'm waiting for a etcd-io member to verify that this patch is reasonable to test. If it is, they should reply with Regular contributors should join the org to skip this step. Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
Fixes #22082
Problem
If an
Unlockdelete commits but its response is lost, the oldMutexretains its key and create revision. A later lock using the same session and
prefix reuses the key at a newer create revision. Retrying the stale
Unlockcurrently deletes that newer lock.
Root cause
Mutex.Unlockdeletes by key name only, without verifying that the key isstill the incarnation acquired by that
Mutex.Change
Fence the delete in one transaction with
Mutex.IsOwner(), which compares thekey's current create revision with the revision recorded at acquisition. A
stale comparison performs no delete; after a successful RPC, the old local
mutex handle is retired as before.
The regression test adapts the reproducer from #22082. It simulates a committed
delete whose response is replaced by
DeadlineExceeded, reacquires theidentical key with the same session, and verifies that retrying the old unlock
preserves the newer create revision.
Verification
The new test failed before the production change because the newer key was
deleted. It passes after the change.
go test ./integration/clientv3/concurrency -run '^TestMutexStaleUnlockDoesNotDeleteSameSessionRelock$' -count=10go test -race ./integration/clientv3/concurrency -run '^TestMutexStaleUnlockDoesNotDeleteSameSessionRelock$' -count=1go test ./integration/clientv3/concurrency -count=1go test ./concurrency -count=1go vet ./concurrencymake verify-lintmake verify-mod-tidygit diff --checkThe aggregate
make verifyreachedverify-bombut cannot complete faithfullyon this Darwin/arm64 host: the local BOM generator excludes the amd64-only
Antithesis SDK and therefore differs from the checked-in Linux BOM. Prow's
supported Linux/amd64 checks remain authoritative.
Compatibility
This changes one
DeleteRangeRPC into one transactional compare-and-deleteRPC. There is no public API, documentation, or main-branch changelog change.
Maintainers can decide whether the fix should be backported.