Signal onError instead of hanging when a reactive complex-output command errors#3851
Open
HwangRock wants to merge 1 commit into
Open
Signal onError instead of hanging when a reactive complex-output command errors#3851HwangRock wants to merge 1 commit into
HwangRock wants to merge 1 commit into
Conversation
…and errors Reactive commands backed by EncodedComplexOutput (CF.INFO, BF.INFO, TOPK.LIST, TS.INFO, ...) hang until the command timeout fires when the server replies with an error. SubscriptionCommand.doOnComplete() calls getOutput().get() before checking hasError(); get() runs the ComplexDataParser, which throws on the null payload left by an error reply. That throw escapes doOnComplete() after the completion state has already flipped to COMPLETE, so completeExceptionally() skips onError and the Flux/Mono never terminates. Check hasError() before get(), matching AsyncCommand.completeResult() and MultiOutput. The normal path is unchanged; only error replies are affected, and they now surface as onError instead of hanging.
Collaborator
|
Hey @HwangRock |
Contributor
Author
|
@a-TODO-rov Done, opened #3855 with the repro, root cause, and affected scope. This PR is the fix for it. |
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 #3855
Motivation
Reactive commands backed by
EncodedComplexOutput—CF.INFO,BF.INFO,TOPK.INFO,TOPK.LIST, and any other command whose output is decoded by aComplexDataParser— hang until the command timeout fires when the server replies with an error.Reproduction against a live server:
Before this change the
Mononever terminates; the subscriber waits until the client-side command timeout (default 60s).Root cause
SubscriptionCommand.doOnComplete()inRedisPublishercallsgetOutput().get()before checkinghasError():On an error reply the output holds an error and a
nullpayload.get()runs theComplexDataParser, which throwsIllegalArgumentExceptionon thenulldata. That throw escapesdoOnComplete(), which runs insideCommandWrapper.complete()after the completion state has already been flipped toCOMPLETE.CommandHandlercatches the throw and callscompleteExceptionally(), but itsconsumers != COMPLETEguard is now false, soonErroris never signalled and theFlux/Mononever terminates.The non-reactive paths do not have this problem because they check
hasError()first:AsyncCommand.completeResult()andMultiOutputboth surface the error without ever callingget(). Only the reactive path had the ordering reversed. This was latent untilComplexDataParser-based outputs (RESP3 complex replies) madeget()able to throw.Modification
Check
hasError()beforeget()indoOnComplete(), matchingAsyncCommand.completeResult():The
dissolve/onNext/StreamingOutputlogic is unchanged. The normal path (hasError() == false) is byte-for-byte identical; only error replies change behaviour, and they now surface asonErrorinstead of hanging. Normal empty replies (hasError() == false,data == null) are unaffected — the parser returnsnullas before.Result
cfInfoOnMissingKeyErrorsInsteadOfHangingtoRedisCuckooFilterReactiveIntegrationTests. Fails with a 5s timeout before the change, passes after.redis:8.