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

java ditto-client threads leakage #87

Closed
desislava-marinova opened this issue Sep 27, 2020 · 1 comment · Fixed by #88
Closed

java ditto-client threads leakage #87

desislava-marinova opened this issue Sep 27, 2020 · 1 comment · Fixed by #88
Labels
bug Something isn't working java
Milestone

Comments

@desislava-marinova
Copy link

desislava-marinova commented Sep 27, 2020

Steps executed:

  • Open java ditto-client
  • call registerForThingChanges
  • destroy the client

Every DittoClients seems to occupy ~10 threads in this scenario
When all clients are destroyed, the following threads are still open

Number of opened clients Number of opened threads Number of ditto-client--adaptable-bus threads after destroy Number of pool-X-thread-Y threads after destroy
10 102 22 10
20 202 42 20
100 1002 202 100

The district thread stacks are as follow (if needed I can upload the whole stack trace)

"ditto-client--adaptable-bus-74ef6b92-2a09-4b4f-ad24-c3b3689880c7-1" Id=1406 WAITING on java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject@2f5ac102
	at sun.misc.Unsafe.park(Native Method)
	-  waiting on java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject@2f5ac102
	at java.util.concurrent.locks.LockSupport.park(LockSupport.java:175)
	at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2039)
	at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1081)
	at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:809)
	at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1067)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1127)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	...

"ditto-client--adaptable-bus-0d61b4fa-984c-4bdf-abf0-f06f951e78f8-2" Id=1396 WAITING on java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject@895416d
	at sun.misc.Unsafe.park(Native Method)
	-  waiting on java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject@895416d
	at java.util.concurrent.locks.LockSupport.park(LockSupport.java:175)
	at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2039)
	at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1088)
	at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:809)
	at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1067)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1127)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	...

"pool-99-thread-1" Id=1394 WAITING on java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject@71a06021
	at sun.misc.Unsafe.park(Native Method)
	-  waiting on java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject@71a06021
	at java.util.concurrent.locks.LockSupport.park(LockSupport.java:175)
	at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2039)
	at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:442)
	at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1067)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1127)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)
@desislava-marinova
Copy link
Author

The problem described above is only when no events are received at all. If there are events the number of leaked threads is a lot more.

DerSchwilk added a commit to bosch-io/ditto-clients that referenced this issue Sep 28, 2020
…essagingProvider to prevent blocked threads after closing the client

Signed-off-by: David Schwilk <david.schwilk@bosch.io>
DerSchwilk added a commit to bosch-io/ditto-clients that referenced this issue Sep 28, 2020
Signed-off-by: David Schwilk <david.schwilk@bosch.io>
DerSchwilk added a commit to bosch-io/ditto-clients that referenced this issue Sep 28, 2020
Signed-off-by: David Schwilk <david.schwilk@bosch.io>
DerSchwilk added a commit to bosch-io/ditto-clients that referenced this issue Sep 29, 2020
Signed-off-by: David Schwilk <david.schwilk@bosch.io>
yufei-cai added a commit that referenced this issue Sep 29, 2020
Issue #87: Prevent leakage of AdaptableBus threads after closing the client
@thjaeckle thjaeckle added this to the 1.3.0 milestone Sep 30, 2020
@thjaeckle thjaeckle added java bug Something isn't working labels Sep 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working java
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants