javaee / grizzly

Writing scalable server applications in the Java™ programming language has always been difficult. Before the advent of the Java New I/O API (NIO), thread management issues made it impossible for a server to scale to thousands of users. The Grizzly NIO framework has been designed to help developers to take advantage of the Java™ NIO API.
https://javaee.github.io/grizzly/
Other
222 stars 60 forks source link

DelayQueue of AbstractThreadPool keeps reference to abandoned worker thread #1867

Closed glassfishrobot closed 7 years ago

glassfishrobot commented 7 years ago

Grizzly's AbstractThreadPool uses a DelayedExecutor to manage transaction timeouts of worker threads. We are using the following configuration for our grizzly server:

core worker threads: 2 maximum worker threads: 16 idle worker timeout: 30s transaction timeout: 10min

In case worker threads are scaled up and later removed regularly the DelayedExecutor.DelayQueue used by the AbstractThreadPool keeps a reference to the worker, which may lead to an OOM situation with huge amount of worker threads being referenced in that queue.

The worker threads are never removed from that queue in case a worker scale down is performed, since they are not removed in the onWorkerExit method, altough they were added in the onWorkerStarted method.

Affected Versions

[2.3.27]

glassfishrobot commented 7 years ago

Reported by MarcBecker

glassfishrobot commented 7 years ago

@rlubke said: Thank you for the report.

Could you please test with this snapshot and verify resolution in your environment?

Thanks!

[1] https://www.dropbox.com/s/162hfsf56exs6ys/grizzly-framework-2.3.28-SNAPSHOT.jar?dl=0

glassfishrobot commented 7 years ago

marcbecker said: Thanks for looking into this so quickly. The queue is correctly cleaned up in my scenario, when using the 2.3.28 snapshot. Any hint on when we could expect a release of that fix? Our workaround is currently to disable the transaction timeout, which is however only a temporary solution for us to solve the memory leak.

glassfishrobot commented 7 years ago

@rlubke said: I'll try to get a release out at the end of this week or early next.

glassfishrobot commented 7 years ago

This issue was imported from java.net JIRA GRIZZLY-1867

glassfishrobot commented 7 years ago

Marked as fixed on Thursday, September 22nd 2016, 7:56:19 am