Resolve hung threads in WebSphere (WSVR0605W)

Home > Search
  by

A JVM will have a single process, and the process identification number (PID) can be found using the ps command. A process will contain numerous threads. Some examples of threads are the JVMs garbage collector, a code optimizer thread, and a finalizer thread.

ps -ef | grep jvm_name

 

A thread is typically consider hung when the thread has been active for 12 minutes, because most threads should only take a few moments to complete. As an example, a thread may be hung when an application issues a SQL request, and the database does not issue a response in a timely manner.  Hung threads are problematic, because they use system resources (CPU, memory), and usually, the thread is unintentially hung, which means system resources are unnecessarily being used.

IBMs Support Assistant Thread and Monitor Dump Analyzer tool can be used to spot hung threads. Or, the SystemOut.log will contains events that spot hung threads.


Replicate hung thread

This assumes you have created your first dynamic web project in Eclipse. If you have not yet created a package, in the left panel of Eclipse, expand the Java Resources folder, right click on the src folder, and select New > Package. Give the package a name, such as com.main.servlet and select Finish. Right click on the newly created package and select New > Servlet. Give the servlet a name, such as HungThread, and select Finish.

In the doGet method section of the markup, add the following markup.

while(true) {
    try {
        Thread.sleep(1000);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
}

 

Add the following markup to your web.xml file.

<servlet>
   <servlet-name>HungThread</servlet-name>
    <servlet-class>com.jwt.servlet.HungThread</servlet-class>
</servlet>
 
<servlet-mapping>
    <servlet-name>HungThread</servlet-name>
    <url-pattern>/hungthread</url-pattern>    
</servlet-mapping>

 

Export the WAR or EAR to your application server (Tomcat, WebSphere). Now, when navigating to www.example.com/app_name/myServlet, the page should load endlessly.

 

 


SystemOut.log

In the SystemOut.log, a hung thread will be identified by event code WSVR0605W, and when the thread is no longer hung, event WSVR0606W will be found in the log. When hung threads are detected, the number of hung threads will be identifed, along with how long the threads have been hung. In this example, there is 1 hung thread at 9:00 am for 765432 milli seconds, which is about 12 minutes.

[02/05/18 09:00:00:000 CDT] 0000002e ThreadMonitor W   
WSVR0605W: Thread "WebContainer : 2" (0000012f) has been active for 765432 milliseconds and may be hung.  
There is/are 1 thread(s) in total in the server that may be hung.

 

The SystemOut.log may list events that correlate to the hung thread. In this example, you would look for events near 8:48 (12 minutes prior to the hung thread event). The list of possible causes of hung threads if far to vast to list. Each hung thread will need to be looked at. However, some common causes of hung threads are long database connections, some sort of system scan (such as anti-virus), or some sort of long running batch job. Not all hung threads are necessarily bad - for example, an anti-virus scan may be an OK reason for a long running thread.

Once the threads are no longer hung, the SystemOut.log will list the following event.

[02/05/18 09:35:00:000 CDT] 0000002e ThreadMonitor W   
WSVR0606W: Thread "WebContainer : 2" (0000012f) was previously reported to be hung but has completed.

 



Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.




Please enter in the box below so that we can be sure you are a human.




Comments