Repository navigation
fix(decoder): copy collection in ContainsDecoder to prevent IndexOutOfBoundsException during watchdog renewal (#7402) - #7404
Open
ronitgupta138 wants to merge 1 commit into
Conversation
…fBoundsException during watchdog renewal (redisson#7402) Signed-off-by: Ronit Gupta <[email protected]>
Member
|
same comment to this fix #7403 (review) |
Contributor
Author
|
Hi @mrniko, Thanks for the feedback. In normal sequential execution, However, in if (ex instanceof RedisNoScriptException) {
MasterSlaveEntry entry = connectionManager.getEntry(key);
return loadScript(entry.getClient(), script).thenCompose(r3 ->
syncedEval(timeout, syncMode, retry, key, codec, evalCommandType, script, keys, params));
}When Redis returns Snapshotting the list protects against mutable state leaking into retried or re-executed decoders. |
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.
Problem
In
ContainsDecoder, passing aListpreviously skipped copying and stored the instance directly:During lock watchdog renewal in
LockTask.renew(), the caller dispatches the command and immediately registers a completion callback that mutates the samekeyslist:When a response arrives late or is decoded across a retry/channel switch after the callback has already mutated the collection,
decode()iterates overpartsmatching the original number of keys, but accessesargs.get(index)from the shrunken list, throwing:Because this exception aborts decoding, the renewal future never completes, stalling the watchdog loop and allowing held locks to expire under
lockWatchdogTimeout.Solution
Always defensive-copy the collection into a new
ArrayListinContainsDecoderconstructor:Added JUnit 5 regression test suite
ContainsDecoderTestverifying:IndexOutOfBoundsException.Fixes #7402.