Skip to content
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

Akka.Streams: Akka.Streams.Util.IteratorAdapter`1.Next() Collection modified on enumeration exception #7513

Open
Aaronontheweb opened this issue Mar 4, 2025 · 0 comments

Comments

@Aaronontheweb
Copy link
Member

Version Information
Version of Akka.NET? 1.5.38
Which Akka.NET Modules? Akka.Streams

Describe the bug

Not entirely sure what causes it just yet, but here's the stack trace:

   at Akka.Streams.Util.IteratorAdapter`1.Next()
   at Akka.Streams.Implementation.Fusing.StatefulSelectMany`2.Logic.PushPull()
   at Akka.Streams.Implementation.Fusing.StatefulSelectMany`2.Logic.OnPush()
--- End of stack trace from previous location where exception was thrown ---
   at UserQuery.Main(), line 51

  at System.Collections.Generic.List`1.Enumerator.MoveNextRare()
   at System.Linq.Lookup`2.Create(IEnumerable`1 source, Func`2 keySelector, IEqualityComparer`1 comparer)
   at System.Linq.GroupedEnumerable`2.GetEnumerator()
   at System.Linq.Enumerable.SelectManySingleSelectorIterator`2.MoveNext()
   at Akka.Streams.Util.IteratorAdapter`1.HasNext()

To Reproduce

If I take the same sample from #7512 and change it slightly:

.GroupBy(50, r => r.EntityId) // triggers exception

That will trigger the problem. You can modify the LINQPad sample I created for #7512 here: https://share.linqpad.net/bkgp72uf.linq

Expected behavior

Should process without error.

Actual behavior

It's slightly racy, but very frequently we get an "collection modified while enumerating" exception.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant