Skip to content

Signal onError instead of hanging when a reactive complex-output command errors - #3851

Merged
a-TODO-rov merged 2 commits into
redis:mainfrom
HwangRock:fix/reactive-error-hang
Aug 24, 2026
Merged

a-TODO-rov merged 2 commits into
redis:mainfrom
HwangRock:fix/reactive-error-hang

Conversation

@HwangRock

@HwangRock HwangRock commented Jul 18, 2026 •

Copy link
Copy Markdown
Contributor

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 a ComplexDataParser — hang until the command timeout fires when the server replies with an error.

Reproduction against a live server:

StepVerifier.create(reactive.cfInfo("does-not-exist-key"))
    .expectError(RedisCommandExecutionException.class)
    .verify(Duration.ofSeconds(5));

Before this change the Mono never terminates; the subscriber waits until the client-side command timeout (default 60s).

Root cause

SubscriptionCommand.doOnComplete() in RedisPublisher calls getOutput().get() before checking hasError():

Object result = getOutput().get();      // runs the parser
if (getOutput().hasError()) { ... }     // never reached

On an error reply the output holds an error and a null payload. get() runs the ComplexDataParser, which throws IllegalArgumentException on the null data. That throw escapes doOnComplete(), which runs inside CommandWrapper.complete() after the completion state has already been flipped to COMPLETE. CommandHandler catches the throw and calls completeExceptionally(), but its consumers != COMPLETE guard is now false, so onError is never signalled and the Flux/Mono never terminates.

The non-reactive paths do not have this problem because they check hasError() first: AsyncCommand.completeResult() and MultiOutput both surface the error without ever calling get(). Only the reactive path had the ordering reversed. This was latent until ComplexDataParser-based outputs (RESP3 complex replies) made get() able to throw.

Modification

Check hasError() before get() in doOnComplete(), matching AsyncCommand.completeResult():

if (getOutput().hasError()) {
    onError(ExceptionFactory.createExecutionException(getOutput().getError()));
    return;
}
Object result = getOutput().get();

The dissolve/onNext/StreamingOutput logic is unchanged. The normal path (hasError() == false) is byte-for-byte identical; only error replies change behaviour, and they now surface as onError instead of hanging. Normal empty replies (hasError() == false, data == null) are unaffected — the parser returns null as before.

Result

  • Added cfInfoOnMissingKeyErrorsInsteadOfHanging to RedisCuckooFilterReactiveIntegrationTests. Fails with a 5s timeout before the change, passes after.
  • Existing reactive happy-path integration tests for CF/BF/TopK pass unchanged (50 tests): the normal path is untouched.
  • Verified against redis:8.

Note

Medium Risk
Touches reactive command completion in RedisPublisher, a core path for all reactive subscribers. The change is a small reorder of existing error handling and only affects error replies.

Overview
Reactive commands with complex parsers (CF.INFO, BF.INFO, TOPK.INFO, etc.) no longer hang when Redis returns an error. SubscriptionCommand.doOnComplete() now checks hasError() before get(), matching AsyncCommand.completeResult(), so a null error payload is not parsed and the subscriber gets RedisCommandExecutionException instead of waiting until timeout.

Adds cfInfoOnMissingKeyErrorsInsteadOfHanging to cover the missing-key CF.INFO case.

Reviewed by Cursor Bugbot for commit 8f55099. Bugbot is set up for automated code reviews on this repo. Configure here.

…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.
@a-TODO-rov

Copy link
Copy Markdown
Collaborator

Hey @HwangRock
Could you please open an issue (or a Bug) for that one first. Seems that a lot of commands would be affected.

@HwangRock

Copy link
Copy Markdown
Contributor Author

@a-TODO-rov Done, opened #3855 with the repro, root cause, and affected scope. This PR is the fix for it.

@a-TODO-rov
a-TODO-rov merged commit d3526a2 into redis:main Aug 24, 2026
14 of 16 checks passed
HwangRock added a commit to HwangRock/lettuce that referenced this pull request Sep 7, 2026
The RedisPublisher reactive error-handling hang (redis#3851) is fixed and present
on this branch via the upstream merge, so the test no longer hangs and is
re-enabled. Verified against the dockerized 8.10 environment.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Reactive complex-output commands hang on server error instead of signalling onError

2 participants