• Post Reply Bookmark Topic Watch Topic
  • New Topic

Deadlock in Executor Service  RSS feed

 
Chandra Veera
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I have started a process with 8 threads using Executor service. It ran for 5 hours without any issue and then we observe a deadlock. Out of 8 threads, 3 threads are in WAITING state and others are in RUNNABLE state.
And all most every time, this is happening after process run for some long duration.

Below are the stack traces for the worker threads and master thread. Any help or direction would be greatly appreciated.

Worker Thread Stack Trace:


Master Thread Stack Trace:



Regards
Chan
 
Les Morgan
Rancher
Posts: 779
19
C++ Java MySQL Database Netbeans IDE Oracle Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So you only have this problem on some long runs--from your statement it does not happen every time. This is what I like to refer to as a "Twilight Zone Scenario"--it does it sometimes, but why?

This is how I approach this type of problem:

Since it only does it on long runs, what is happening on long runs that may not be happening on shorter runs or on all long runs? The answer I come up with most often is resources. Is there a resource leak, that is causing greater stress on the environment; is the system outside the app being stressed; am I relinquishing resources in an absolute "text book" manner; is my garbage collection still working appropriately; and etc.

Yes, there are a lot of things in the "Twilight Zone Scenario" that could be causing or contributing to the problem, but they all have to be checked all the way from your server configuration and operation to how you are dealing with threading and resources in your app.

Good luck, and it can be a maddening exercise in micro inspection of your system, or it could be a fortuitous tweak of 1 line of code--either way--I do not envy your task.
 
Karthik Shiraly
Bartender
Posts: 1210
25
Android C++ Java Linux PHP Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

It looks like you have created a fixed thread pool of 8 threads, which by default stores tasks in a LinkedBlockingQueue.
From its source code, this stack trace just means LBQ.take() is awaiting some task to be added to the queue, which is presumably empty at that point in time.
This is expected behaviour. Why do you say there's a deadlock?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!