Repository navigation
Fixed - lock watchdog renewal timeouts accumulate after the renewal task restarts - #7459
Merged
Merged
Conversation
…ask restarts redisson#7454 stop() only cleared the running flag and left the already armed timeout in the timer, so each restart of the renewal task added one more periodic timeout. Allow at most one pending timeout. Signed-off-by: OverSky <[email protected]>
Member
|
Thanks for contribution |
Member
Contributor
Author
|
Thanks for the refactoring, LGTM. Arming the timeout after |
Member
|
Good. Thank you |
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.
Fixes #7454.
Problem
RenewalTask.stop()only clearsrunningand leaves the already armed timeout in the timer. When a lock is added again,add()→tryRun()→schedule()arms a second timeout. When the old one fires it seesrunning == trueand keeps rescheduling itself. Each time the set of renewed locks goes from empty to non-empty, one more periodic task is added. A worker that takes one lock at a time ends up sending a fast-growing stream of renewal scripts.Fix
As suggested in #7454 by garvit-joshi (thanks for the analysis): a
scheduledflag allows at most one pending timeout.run()clears it, andschedule()arms a new timeout only if it wins the CAS. A lock added while a timeout is pending gets its first renewal when that timeout fires, withinlockWatchdogTimeout / 3, the same as a lock added while the task is already running.Test
Added
RedissonLockExpirationRenewalTest#testRenewalTimeoutsDontAccumulate: 20 lock/unlock cycles, then a 3 s hold withlockWatchdogTimeout1000 ms, countingEVAL/EVALSHAcalls during the hold.Also checked (Windows 11, Docker, Redis 7, JDK 25)
lockWatchdogTimeout3000 ms, 20 s): 1,457 renewal scripts on master, 12 with the fixRedissonLockExpirationRenewalTest,RedissonLockTest,RedissonReadWriteLockTest,RedissonFairLockTest,RedissonMultiLockTest,RedissonFasterMultiLockTest,renewal.*Test: all pass except the*InClustertests (cluster containers don't start on my Docker for Windows) andRedissonFairLockTest#testConcurrency_MultiInstance_Ordering.testConcurrency_MultiInstance_OrderingandRedissonLockTest#testInClusterfail the same way on unpatched master; the other cluster tests fail with the same container-startup error.checkstyle:checkpasses