-
Notifications
You must be signed in to change notification settings - Fork 672
FluxReceive hangs, sometimes, on subsequent subscribers #503
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Commit #c187cb2 introduced proactive rejection of multiple subscribers in ReactorClientHttpResponse, instead of hanging indefinitely as per reactor/reactor-netty#503. However FluxReceive also rejects subsequent subscribers if the response is consumed fully, as opposed to being canceled, e.g. as with bodyToMono(Void.class). In that case, a subsequent subscriber causes two competing error signals to be sent, and one gets dropped and logged by reactor-core. This fix ensures that a rejection is raised in ReactorClientHttpResponse only after a cancel() was detected. Issue: SPR-17564
The following workaround was added to 5.1.3, which led to #540 and SPR-17564. It turns out the root cause was that both Reactor Netty and the Spring Framework were signalling IIlegalStateException on a subsequent subscriber, if the response was read in full by the first subscriber, but it works okay if the first subscriber cancels (e.g. The current behavior seems broken and our workaround proved fragile. I see no good reasons why subsequent subscribers, after a cancellation, should not be rejected as is the case with multiple subscribers during the course of reading. Even if there is some intent like retries, certainly indefinite hanging doesn't seem right either. Once again the reason for talking about multiple subscribers in the first place is the need to ensure that response is drained always, and sometimes we can't be sure if it has been consumed or not. So we try to consume again and rely on being kicked out if it there has been a consumer already. If you'd like to keep the current behavior, then please consider exposing a way to do the equivalent of |
@violetagg the following test here can be used to debug the issue. The scenario is this:
I believe this behavior is somewhat intentional to keep the door open to allow re-subscribing but I'm not sure there is a clear purpose at this time. @smaldini any more insight? |
@rstoyanchev This PR #1185 should fix the issue. Can you please verify it? |
I'm closing this issue as a fix is provided with #1185 |
The workaround has been removed in Spring Framework master and 5.2.x. |
FluxReceive
rejects multiple subscribers but only if the second subscribes while first one is still active. Once a subscriber completes and thereceiver
field is cleared, a second subscriber will not be rejected and will not receive further signals.One reason to read a second time is to ensure a client response has been drained from at a place where it isn't known if it has been consumed or not. The second attempt to read relies on either draining successfully or getting an error, not hanging indefinitely.
The text was updated successfully, but these errors were encountered: