-
Notifications
You must be signed in to change notification settings - Fork 161
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
Fix uncaught decider exception in Split with Supervision.resumingDecider #1207
Merged
mdedetrich
merged 1 commit into
apache:main
from
mdedetrich:fix-exception-not-being-caught-in-split-resuming-decider
Mar 19, 2024
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.
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.
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.
It seems like this is a genuine mistake when the test was originally written (remember that this test never passed, it was written for the future when supervision strategy propagation would be implemented which occurred later as a result of #252).
Logically when you read the test, its expected that when you do
expectNext
that previously an element should have been sent withsendNext
and its also the same in the equivalentgroupBy
test and alsosplitWhen
testThere 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 thought about this again, I may be wrong and the test is indeed valid as its written right now because its
splitAfter
so its its meant to be skipping the next element due to exception being thrown, in which case we have to drop one element and then dopull(in)
???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.
Yes, the element which case the exception is dropped now.
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.
So to confirm, the current PRs implementation is correct and the test as originally written was wrong?
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.
As the
downstreamSubscription.request(100)
, I think the orign test should be right too, but its a little strange now ,that we need send thenext(7)
to make the next sub source be ready.I think we should call
now inside the
SubstreamHandler#onPush
when the decision isSplitAfter
too to keep the behavior the same, as it just a dummy Source.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.
@mdedetrich in the test, it requests 10, so the SubSource is expected to be there after 6.
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.
But its also sending a completion because of this condition
if (elem == 3) throw exc else elem % 3 == 0
(i.e.6 % 3
== 0 so the split happens right after that) which is why the test is failing withat
val substream2 = subscriber.expectNext()
because there isn't going to be aexpectNext
, it's expecting a completion instead.Note that at this point, we are dealing with the normal logic of
SplitWhen
. The new functionality of skipping exceptions withSupervisionDecider.resume
occurs earlier whenelem == 3
so we are past that and just testing happy path logic ofSplitAfter
which is not changed at all (and it shouldn't be either!).This is why I think that part of the test is written incorrectly. In fact you can argue it can even be removed since it has nothing to do with recovering from thrown exceptions with
SupervisionDecider.resume
, its testing something entirely different (but I would personally leave it there now so its consistent with the other tests).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.
**1.
val substream2 = subscriber.expectNext()
, thesubscriber
is not expecting acomplete
, otherwise, the callsendNext(7)
will cause issue because the origin source is already completed.The problem here is when the
stream2
be generated, I expected the behavior the same, just after the6 % 3 == 0
, wdyt @samueleresca @mdedetrich**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 am not saying that this is necessarily wrong, just that its a completely separate issue from what this PR is changing/solving. Or to put it differently, this behaviour is the same as current Pekko since at this point i.e.
we are past recovering from an exception (furthermore if we are somehow changing some fundamental behaviour with
SplitAfter
then other tests would fail, but they are all passing without any changes). The critical part of the test specifically dealing with recovering from exception and resuming isAnd this part is completely unchanged from how the test was originally written.
Given that, I think it makes sense to file a separate issue if this behaviour about completing after a split needs to change and hence to tackle it separately. The only exception to this that I can think of is that some state is not being reset correctly
in the
case Supervision.Resume => pull(in)
block, but if thats the case it would also error out earlier since that block is only executed when recovering from exceptions inonPush
(and again thats only whenelem
is 3, not 6)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.
Thanks folks, I appreciate the detailed explanation. And yes, I was diverting away (not on purpose) from the original goal of the test
looks good to me