Skip to content

Fix ForkJoinExecutor / Dispatcher Leak #3734

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

Merged

Conversation

Aaronontheweb
Copy link
Member

Have a reproduction spec for #2640 in here, but not a fix yet.

threads.Count.Should().Be(4, "Expected 4 distinct threads in this example");

await Sys.Terminate();
AwaitAssert(() => threads.Values.All(x => x.IsAlive == false).Should().BeTrue("All threads should be stopped"));
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This assertion currently fails - the Task from Terminate() completes without killing off any of the ForkJoinExecutor threads.

@Aaronontheweb
Copy link
Member Author

Looks like the real fix to this bug is completing all outstanding work items inside the IScheduler upon shutdown in order to guarantee that dispatchers are terminated.

@Aaronontheweb Aaronontheweb marked this pull request as ready for review March 11, 2019 23:42
{
try
{
task.Action.Run();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this was the major fix - the JVM has equivalent code too; need to make sure everything gets processed upon IScheduler shutdown.

Copy link
Contributor

@izavala izavala left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left a comment I'd like to get some clarity on to make sure I fully understand what is going on.

Copy link
Contributor

@izavala izavala left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Aaronontheweb Aaronontheweb merged commit 2392e61 into akkadotnet:dev Mar 12, 2019
@Aaronontheweb Aaronontheweb deleted the fix-2640-ForkJoinExecutorLeak branch March 12, 2019 14:56
madmonkey pushed a commit to madmonkey/akka.net that referenced this pull request Jul 12, 2019
* close akkadotnet#2640 - fixed shutdown routine of HashedWheelTimerScheduler
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants