Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the diagnosis of Thread Dump and Java applications

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

What this article shares with you is about the diagnosis of Thread Dump and Java applications. The editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article.

1,Solaris OS

-''(Control-Backslash)

Kill-QUIT

2, HP-UX/UNIX/Linux

Kill-3 PID

PID gets the following methods

Ps-efHl | grep 'java' * *. **

3,Windows

Press Ctrl-break directly on the program of MSDOS window

Some Java application servers run on the console, such as Weblogic, in order to facilitate access to threaddump information, when weblogic starts, it is best to redirect its standard output to a file, use the "nohup sh startWebLogic.sh > start.log &" command, execute "kill-3", and Stack trace will be output to start.log. The Thread Dump of Tomcat will be output to the command line console or to the catalina.out file of logs. In order to reflect the dynamic change of thread state, thread dump needs to be done several times in succession, each time with an interval of 10-20s.

Generate Thread Dump under IBM JVM:

With IBM's JVM on AIX, javacore files (about cpu) and heapdump files (about memory) are generated by default when memory overflows. If you do not refer to the following methods:

1 choose one cluster member, set the following before this server start:

Set the following environment variables before was startup (can be added to the startup script)

Export IBM_HEAPDUMP=true

Export IBM_HEAP_DUMP=true

Export IBM_HEAPDUMP_OUTOFMEMORY=true

Export IBM_HEAPDUMPDIR=

2 please use set command to make sure you do not have DISABLE_JAVADUMP parameter

Then start this cluster member.

Use the set command to check the parameter settings, make sure DISABLE_JAVADUMP is not set, and then start server

3 when you find free memory

< 50% when no heavy access, please run kill -3 执行kill -3命令可以生成javacore文件和heapdump文件(pid为was java进程的id号,可以用ps -ef|grep java 查到),可以多执行几次,按照下面操作进行 ps -ef >

Psef1.txt

Psaux > psaux1.txt

Vmstat 5 10 > vmstat.txt

Kill-3

Wait for 2 mins

Kill-3

Wait for 2 mins

Kill-3

Netstat-an > netstat2.txt

Ps-ef > psef2.txt

Psaux > psaux2.txt

Copy the txt and / usr/WebSphere/AppServer/javacore* and heapdump files generated above locally, and then delete these files because they take up a large amount of file system space.

Copy the logs generated today under the / usr/WebSphere/AppServer/logs/wlmserver1 (or 2) directory

Apply the common thread state of the server Web container in the javacore or Threaddump file generated by IBM JVM:

Idle thread: a thread that is ready to accept requests but does not establish a connection with the plug-in or client

Keep-Alive thread: a thread that is ready to accept requests and has established a connection with a plug-in or client

Thread that is accepting the request: a thread is reading the contents or headers of the request

Here's how the various threads behave in javacore or Threaddump:

Idle thread:

"Servlet.Engine.Transports: 20" (TID:0x427F190, sys_thread_t:0x15D175E8, state:R, native ID:0xBB8) prio=5

At java.lang.Object.wait (Native Method)

At java.lang.Object.wait (Object.java:429)

At com.ibm.ws.util.BoundedBuffer.take (BoundedBuffer.java:161)

At com.ibm.ws.util.ThreadPool.getTask (ThreadPool.java (Compiled Code)) at com.ibm.ws.util.ThreadPool$Worker.run (ThreadPool.java (Compiled Code))

Keep-alive thread (non-SSL mode):

"Servlet.Engine.Transports: 20" (TID:0x427F190, sys_thread_t:0x15D175E8, state:R, native ID:0xBB8) prio=5

At java.net.SocketInputStream.socketRead (Native Method)

At java.net.SocketInputStream.read (SocketInputStream.java:86)

At com.ibm.ws.io.Stream.read (Stream.java)

At com.ibm.ws.io.ReadStream.readBuffer (ReadStream.java)

At com.ibm.ws.io.ReadStream.read (ReadStream.java)

At com.ibm.ws.http.HttpRequest.readRequestLine (HttpRequest.java)

At com.ibm.ws.http.HttpRequest.readRequest (HttpRequest.java)

At com.ibm.ws.http.HttpConnection.readAndHandleRequest (HttpConnection.java)

At com.ibm.ws.http.HttpConnection.run (HttpConnection.java)

At com.ibm.ws.util.CachedThread.run (ThreadPool.java)

Keep-alive thread (SSL mode):

"Servlet.Engine.Transports: 12" (TID:0x458DBA18, sys_thread_t:0x60B297C0, state:R, native ID:0x427E) prio=5

At java.net.SocketInputStream.socketRead (Native Method)

At java.net.SocketInputStream.read (SocketInputStream.java (Compiled Code))

At com.ibm.sslite.s.a (Unknown Source) (Compiled Code)

At com.ibm.sslite.s.b (Unknown Source) (Compiled Code)

At com.ibm.sslite.s.a (Unknown Source) (Compiled Code)

At com.ibm.sslite.a.read (Unknown Source) (Compiled Code)

At com.ibm.jsse.a.read (Unknown Source) (Compiled Code)

At com.ibm.ws.io.Stream.read (Stream.java (Compiled Code))

At com.ibm.ws.io.ReadStream.readBuffer (ReadStream.java (Inlined Compiled Code))

At com.ibm.ws.io.ReadStream.read (ReadStream.java (Inlined Compiled Code))

At com.ibm.ws.http.HttpRequest.readRequestLine (HttpRequest.java (Compiled Code))

At com.ibm.ws.http.HttpRequest.readRequest (HttpRequest.java (Compiled Code))

At com.ibm.ws.http.HttpConnection.readAndHandleRequest (HttpConnection)

At com.ibm.ws.http.HttpConnection.run (HttpConnection.java (Compiled Code))

At com.ibm.ws.util.ThreadPool$Worker.run (ThreadPool.java:672)

The thread accepting the request:

At java.net.SocketInputStream.socketRead (Native Method)

At java.net.SocketInputStream.read (SocketInputStream.java:85)

At com.ibm.ws.io.Stream.read (Stream.java:17)

At com.ibm.ws.io.ReadStream.readBuffer (ReadStream.java:411)

At com.ibm.ws.io.ReadStream.read (ReadStream.java:110)

At com.ibm.ws.http.HttpConnection.run (HttpConnection.java:448)

At com.ibm.ws.util.ThreadPool$Worker.run (ThreadPool.java:672)

Common thread states of Sun JVM:

For thread dump information, the main concern is the state of the thread and its execution stack

The state of a thread generally falls into three categories

Runnable (R): currently available thread

Waiting on monitor (CW): thread active wait

Waiting for monitor entry (MW): thread and other locks

Generally focus on threads in the first and third states.

Cpu is busy and pays attention to the threads of runnable.

Cpu is idle and pays attention to the threads of waiting for monitor entry.

A typical deadlock is due to a request for resources from the same weblogic instance server in a server-side application, such as servlet

The solution is to put the servlet into another execution queue to execute.

Here is a typical deadlock thread (note the STUCK keyword):

"[STUCK] ExecuteThread:'2' for queue: 'weblogic.kernel.Default (self-tuning)'" daemon prio=10 tid=02fe9a18 nid=35 lwp_id=7518924 runnable [440dd000..440db878]

At java.net.SocketInputStream.socketRead0 (Native Method)

At java.net.SocketInputStream.read (SocketInputStream.java:134)

At weblogic.jdbc.oracle.net8.OracleDataProvider.getArrayOfBytesFromSocket (Unknown Source)

At weblogic.jdbc.oracle.net8.OracleDataProvider.readFirstPacketInBuffer (Unknown Source)

At weblogic.jdbc.oracle.net8.OracleDataProvider.readPacket (Unknown Source)

At weblogic.jdbc.oracle.net8.OracleDataProvider.receive (Unknown Source)

At weblogic.jdbc.oracle.net8.OracleNet8NSPTDAPacket.sendRequest (Unknown Source)

At weblogic.jdbc.oracle.OracleImplStatement.fetchNext (Unknown Source)

At weblogic.jdbc.oracle.OracleImplStatement.fetchNext2 (Unknown Source)

At weblogic.jdbc.oracle.OracleImplResultset.fetchAtPosition (Unknown Source)

At weblogic.jdbc.base.BaseImplResultSet.next (Unknown Source)

At weblogic.jdbc.base.BaseResultSet.next (Unknown Source)

-locked (a weblogic.jdbc.oracle.OracleConnection)

At weblogic.jdbc.wrapper.ResultSet_weblogic_jdbc_base_BaseResultSet.next (Unknown Source)

At org.hibernate.loader.Loader.doQuery (Loader.java:685)

You can use top, vmstat or prstat commands to observe the status of system resources under UNIX/Linux

This is what the diagnosis of Thread Dump and Java applications is like. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report