Repository navigation
Conversation
Register expiration renewal before the acquire SET so cancel cannot run before schedule. Cancel renewal synchronously at unlock start so a following acquire cannot re-arm while cancel is still in-flight. On interrupted/cancelled acquire, drop the speculative watchdog and unlock if the SET already succeeded. Signed-off-by: arimu1 <[email protected]>
mrniko
requested changes
Aug 3, 2026
| * and release runs in finally (cancel vs schedule race). See #7272. | ||
| */ | ||
| @Test | ||
| public void testWatchdogDoesNotOutliveInterruptedAcquire() throws Exception { |
Member
There was a problem hiding this comment.
test pass even without changes applied
Author
There was a problem hiding this comment.
@mrniko Good catch — the previous interrupt-loop assertion was too weak and could pass without the production change.
Strengthened coverage in RedissonLockExpirationRenewalTest:
testCancelledTryLockAsyncDoesNotLeaveWatchdog— cancels in-flighttryLockAsyncfutures and asserts the key is not left held/renewed. Intentionally does not callforceUnlock()after a successful cancel (that would mask the leak). Verified locally:- fails on master production (
stillLockedstays true after cancels) - passes with this PR’s cancel handler + pre-schedule path
- fails on master production (
testWatchdogDoesNotOutliveInterruptedAcquire— multi-worker continuous interrupt storm closer to the Watchdog renewal can outlive unlock(): cancelLockRenewal races the acquire's async scheduleExpirationRenewal #7272 reproducer (secondary stress).
Happy to adjust further if you want a different shape.
Replace the flaky interrupt-only assertion with a tryLockAsync cancel path that fails without the production cancel handler (orphan key still held/renewed) and passes with it. Amplify the interrupt storm as a secondary stress case matching the issue reproducer. Signed-off-by: arimu1 <[email protected]>
Author
|
@mrniko Addressed the review note on the test passing without the production change. Added |
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 problem does this PR solve?
Fixes #7272 — lock watchdog renewal can outlive
unlock()whencancelLockRenewalraces the acquire path's asyncscheduleExpirationRenewal.After an interrupted
lockInterruptibly()(or any case where unlock runs before the acquire's post-SET schedule callback), cancel can find no entry and no-op, then the latescheduleExpirationRenewalarms renewal forever. The key's TTL keeps jumping back tolockWatchdogTimeoutwith no holder.How it works
SET(watchdog /leaseTime <= 0path only), so unlock's cancel always sees the entry.Tests
LockEntryTest— counter semantics for speculative register / cancel / reentrant release (no Redis).RedissonLockExpirationRenewalTest#testWatchdogDoesNotOutliveInterruptedAcquire— interrupt + unlock loop must not leave a renewed orphan (Docker Redis).testLockIsNotRenewedAfterInterruptedTryLock, reentrant renew, and basic lock tests pass.Checklist
Signed-off-by: arimu1 <[email protected]>)