-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
groupBy followed by flatMap with "terminal operation" never finishes #596
Comments
FlatMap by default merges a limited number of sources and groupBy may hang if not all of its groups are properly drained. Increasing maxConcurrency with flatMap should help. |
thanks. i fixed it by adding a larger prefetch to the i raised the issue because this seems like an API "gotcha". something might work ok in a smaller test but if the scale is ramped up the stream may hang. |
@osi @simonbasle Is the best recommendation here to increase the prefetch on the groupBy or increase the concurrency on the flatMap? I have a scenario where I do not know upfront how many groups may be there in the groupBy - it feels like the best solution for that is to set the prefetch for groupBy to Integer.MAX_VALUE. |
The general idea I started following was to be conscious of how many items I was flat-map'ing and setting the concurrency appropriately. If I didn't know upfront, I did use |
The following snippet never finishes,
It works if the
groupBy
is given a prefetch ofInteger.MAX_VALUE
In debugging it seems that the request to the upstream eventually falls to 0. Since the
push
ultimately completes, and theflatMap
has a "terminal operation" (thereduce
), my initial expectation was that this would have worked as written.The text was updated successfully, but these errors were encountered: