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
supervison strategy not applied to flatMapMerge #23066
Comments
The mapAsyncUnordered output is the desired output (the whole item from the top-level is dropped when there is a failure in the sub-flow, but the other items that did not have a failure in the sub-flow make it through). I tried other approaches of having different materializers with different supervision strategies in scope for the construction of the outer flow from the inner flows without being able to get the desired behavior, though perhaps I didn't stumble on the right way to do it. |
To clarify, the current |
In the meantime, it seems like at least the docs should be updated to add this to the list, currently on the error handling page (http://doc.akka.io/docs/akka/current/scala/stream/stream-error.html) it lists:
|
Yep. Definitely a quite dated section of the docs. Maybe we should rather list the stages that does honour it rather than the ones that doesn't. |
Actually, the same supervision strategy ignorance is for groupBy, splitWhen,splitAfter, flatMapConcat and flatMapMerge. "propagate failure from map function" in assertAllStagesStopped {
val ex = new Exception("buh")
intercept[TestFailedException] {
Source(1 to 3)
.flatMapMerge(10, i ⇒ if (i == 3) throw ex else blocked)
//if we add the line below test will fail
.withAttributes(ActorAttributes.supervisionStrategy(Supervision.resumingDecider))
.runWith(Sink.head)
.futureValue
}.cause.get should ===(ex)
} This test shows that flatMapMerge has a map that honor supervision strategy however following FlattenMerge that does not. I can think of the following grounding: if we are dealing with subtreams combination - we transparently proceed with events and failures from upstream to downstream and back. So the FlattenMerge is not considering as state transformation. So let me know what way we want to go. |
👍 on this. Any update? |
If there was any updates... they'd be here ;-) Note also that Restart stages are nowadays recommended instead of supervision: https://doc.akka.io/docs/akka/2.5/stream/stream-error.html#delayed-restarts-with-a-backoff-stage |
I think there has been a PR merged since this was opened up that added documentation on all stages that do use the supervision strategy, that's in the Scaladoc/Javadoc though, not in the reference docs. |
Any update about this bug? Which is the best pattern right now to tackle this issue? |
Nobody is actively working on this or you'd see that here. You could give it a try fixing the issue and doing a PR if it is an important issue to you. Might be possible to workaround it with a |
@johanandren How about back off strategy. https://doc.akka.io/docs/akka-stream-kafka/current/errorhandling.html#restarting-the-stream-with-a-backoff-stage or create the KafkaConusumerActor by myself and the subscribe in the pipeline to the topic as they do here https://github.com/kciesielski/reactive-kafka/blob/7dd29719a5d1c6eb70584e67bf9f4dbd7b6d2b39/docs/src/test/scala/sample/scaladsl/ConsumerExample.scala#L328 |
I think the forum (https://discuss.akka.io) is better for that kind of a discussion, let's please keep this issue to be about specifically implementing supervision on the flatMapMerge operator, thanks. |
So I am experiencing this exact behavior as well, I am not sure what the exact technical reasons that @johanandren alluded to at #23066 (comment) but it is very impractical behavior. For my specific circumstance, I have a stream that gets split up into a val decider: Supervision.Decider = { e =>
logger.error("Unhandled exception in stream", e)
Supervision.Stop
} It will just keep on looping forever (which actually in my case involved creating ridiculous amount of calls to S3 with each of them failing due to invalid credentials). I will attempt to do a pull request that explores what would happen if we just propagated the supervision strategy rather than completely ignoring it, at least for my specific usebase the expected behavior if you use |
So I did a bit more digging into my issue and I realized that its actually not due to I made a new ticket with details here #31394 |
I would expect that the flatMapMerge below behave the same as the mapAsyncUnordered:
The output is:
The text was updated successfully, but these errors were encountered: