-
Notifications
You must be signed in to change notification settings - Fork 184
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
Publisher#flatMapMergeSingle catch an propagate unexpected errors downstream #1614
Conversation
…nstream Motivation: Publisher#flatMapMergeSingle relies upon the upstream source to catch unexpected exceptions, cleanup necessary state, and propagate an error back downstream. However in the event the upstream source is a Single it will not be able to propagate an error downstream because it has already sent a terminal signal (multiple terminal signals not allowed by the RS spec). This means the upstream can at best log/swallow the error and downstream may not be notified of the failure. Modifications: - Publisher#flatMapMergeSingle exception handling is modified to instead of propagating the exception upstream, exceptions are caught, upstream is cancelled, and the exception is propagated downstream. Result: Publisher#flatMapMergeSingle usages where downstream operators may throw will cancel upstream and propagate and error downstream.
Ideally |
return; // Poison emittingUpdater. We prematurely terminated, other signals should be ignored. | ||
} | ||
// Release lock after we handle errors, because error handling needs to poison the lock. | ||
if (!releaseLock(emittingUpdater, this)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is a risk that smth inside onErrorHoldingLock
may throw and then lock won't be released
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that is intentional. when onErrorHoldingLock
is called the lock is "poisoned" (aka not unlocked) to prevent future signal delivery.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, thanks for clarifying!
...lk-concurrent-api/src/test/java/io/servicetalk/concurrent/api/PublisherFlatMapMergeTest.java
Outdated
Show resolved
Hide resolved
...k-concurrent-api/src/test/java/io/servicetalk/concurrent/api/PublisherFlatMapSingleTest.java
Outdated
Show resolved
Hide resolved
...etalk-concurrent-api/src/main/java/io/servicetalk/concurrent/api/PublisherFlatMapSingle.java
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀
build failure attributed to #1579 |
another build failure attributed to #1579 |
Motivation:
Publisher#flatMapMergeSingle relies upon the upstream source to catch
unexpected exceptions, cleanup necessary state, and propagate an error
back downstream. However in the event the upstream source is a Single it
will not be able to propagate an error downstream because it has already
sent a terminal signal (multiple terminal signals not allowed by the
RS spec). This means the upstream can at best log/swallow the error and
downstream may not be notified of the failure.
Modifications:
of propagating the exception upstream, exceptions are caught, upstream
is cancelled, and the exception is propagated downstream.
Result:
Publisher#flatMapMergeSingle usages where downstream operators may throw
will cancel upstream and propagate and error downstream.