You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@pekko.apache.org by "He-Pin (via GitHub)" <gi...@apache.org> on 2026/06/20 12:05:47 UTC

[I] GroupBy should support infinite substreams with maxSubstreams=-1 [pekko]

He-Pin opened a new issue, #3102:
URL: https://github.com/apache/pekko/issues/3102

   ### Motivation
   
   `GroupBy` requires a fixed `maxSubstreams` limit. When the number of distinct keys exceeds this limit, the stream fails with `TooManySubstreamsOpenException`. Some use cases (e.g., event routing by tenant/user ID) need to handle an unbounded number of keys without a predefined limit.
   
   ### Current behavior
   
   `StreamOfStreams.scala:485`:
   ```scala
   } else if (activeSubstreamsMap.size + closedSubstreams.size == maxSubstreams) {
     throw tooManySubstreamsOpenException
   }
   ```
   
   Passing `maxSubstreams = -1` technically bypasses the check (sizes can never equal -1), but this is undocumented and not an official API contract.
   
   ### Proposed fix
   
   1. Add explicit guard: `if (maxSubstreams >= 0 && activeSubstreamsMap.size + closedSubstreams.size == maxSubstreams)`
   2. Update Scaladoc in `Flow.scala:groupBy` to document `-1` as "unlimited substreams"
   3. Add `require(maxSubstreams >= -1, ...)` validation
   4. Add tests for `maxSubstreams = -1` with many distinct keys
   5. Document the memory implication: with `allowClosedSubstreamRecreation = false`, `closedSubstreams` grows unbounded. Recommend using `allowClosedSubstreamRecreation = true` with infinite substreams.
   
   ### References
   
   - Inspired by Akka.NET [#7607](https://github.com/akkadotnet/akka.net/pull/7607)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [I] GroupBy should support infinite substreams with maxSubstreams=-1 [pekko]

Posted by "He-Pin (via GitHub)" <gi...@apache.org>.
He-Pin closed issue #3102: GroupBy should support infinite substreams with maxSubstreams=-1
URL: https://github.com/apache/pekko/issues/3102


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [I] GroupBy should support infinite substreams with maxSubstreams=-1 [pekko]

Posted by "He-Pin (via GitHub)" <gi...@apache.org>.
He-Pin commented on issue #3102:
URL: https://github.com/apache/pekko/issues/3102#issuecomment-4758050847

   wdyt, I think this may cause some memory safe issue .


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org