Memory space manipulating in Java(Section four:Problems Resolving - part two)

本文讨论了Java应用程序挂起的现象和处理方法,包括无响应的原因分析,如死锁、无限循环、后台资源等待及性能下降等。通过案例分析了MQ Workflow导致的挂起情况,并提供了排查思路。

2. Hang

2-1. Phenomenon

  You can not get any response from your application even the process is still alive.

  (Check it with ps command)

  I have experienced with such a case:

  1) There is contact came from customer that they have submitted form in somehow a function but got no response back from the WebSphere Application Server even have been waiting for long time.

  2) Continuously, similar contact came from other place said that even login process can not be finished for a long time.

  3) Customer mat see the following error in the SystemOut.log of WebSphere:

 

    [ 06/07/05 13:31:52:601 JST] 14875e8 ThreadMonitor W WSVR0605W : Thread
"Servlet.Engine.Transports : 350" (2333b4c6
0) has been active for 721,162 milliseconds and may be hung. There are
1 threads in total in the server that may be hung.

                                :
                            :

    [ 06/07/05 13:40:52:995 JST] 14875e8 ThreadMonitor W WSVR0605W : Thread
"Servlet.Engine.Transports : 560" (386d34c6
0) has been active for 612,670 milliseconds and may be hung. There are
50 threads in total in the server that may be hung.

    

Here by seeing the last message we got to know 50 Threads have already been hung, and 50 is the number of threads we have defined to the running WebSphere Application Server, which means there is not thread can be available to response to user’s request.

We can not get any other information for the problem except for those I have outlined above, as in most of the case you can not found error information like any exception being thrown in hung problem.

  4)

2-2. Handling

  So with the limited information how can we resolve the problem? We should know firstly how hang can get happened.

  The following reasons can be considered when you get into such a situation:

  1) Bug in your application or module of third party

l         Deadlock

l         Indefinite Loop : could make JVM down with a StackOverflow error

l         Recursive Call: could make JVM down with a StackOverflow error

  2) Waiting for processing of the backend resource

l         Your Thread is waiting for an IO processing, which can be with backend resource like DB, MQ, or with problem like network.

  3) Deterioration of Performance

l         After waiting for a long time, you finally got a response from your application, and then you can consider this reason.

l         Well, we should notice here that reason 2) also can cause such a phenomenon.

l          

 Now we are going to see what should be done when facing a system hung by looking at  the following picture:

    

1.      Pay attention to the words “before stopping the JVM”, as Javadump is so important that if you failed to get it you would have no way to identify what has caused the problem. Java application in hung will not create a Javadump for us, so here I will give a example of how can we get the file manually.

Supposing your java application is a process running on WebSphere Application Server, you can get the Javadump by using one of the following ways:

1)      ThreadAnalyzer: you can download the tool from here:

   http://www7b.software.ibm.com/wsdd/downloads/thread_analyzer.html

2)      wsadmin: given the hostname is hostA, server name is serverA, you can try the following commands to get the output.

# /usr/WebSphere/AppServer/bin/wsadmin.sh -conntype SOAP -hostA -port 8880

wsadmin>set jvm[$AdminControl completeObjectName type=JVM,process=serverA,*]

wsadmin>$AdminControl invoke $jvm dumpThreads

3)       

2.      After getting the Javadump,

1) Try to find out the thread in hang by checking information like status (R: Runnable, CW: Watch & Wait) of threads, stack trace.

In Javadump, the information is described in [XM subcomponent dump routine] section of XM part. Below is a sample for the section (pay attention to red parts):

0SECTION XM subcomponent dump routine

------------------ (omission)

1XMCURTHDINFO Current Thread Details

3XMTHREADINFO "Signal dispatcher" (TID:0x101EB960, sys_thread_t:0x9AE860, state:R, native ID:0x284) prio=5

1XMTHDINFO All Thread Details

------------------ (omission)

2XMFULLTHDDUMP Full thread dump Classic VM (J2RE 1.4.1 IBM Windows 32 build cn1411-20031011, native threads):

------------------ (omission)

3XMTHREADINFO "MQBindingsQMThread4" (TID:0x10551CD8, sys_thread_t:0x53ED8F8, state:CW, native ID:0xA50) prio=5

4XESTACKTRACE at java.lang.Object.wait(Native Method)

4XESTACKTRACE at java.lang.Object.wait(Object.java:438)

4XESTACKTRACE at com.ibm.mq.server.MQThread.run(MQThread.java:1348)

4XESTACKTRACE at java.lang.Thread.run(Thread.java:568)

------------------ (omission)

By checking the stack trace, you can see what method is being called by the thread. This can be useful in situation like Indefinite Loop, as you got to know which method is being ran by the thread by knowing this information.

1)      Try to identify whether the threads is in deadlock condition by referring to [LK subcomponent dump routine] section of LK. Below is a sample for the section:

0SECTION LK subcomponent dump routine

NULL ============================

------------------ (omission)

1LKMONPOOLDUMP Monitor Pool Dump (flat & inflated object-monitors):

//*Note1

2LKMONINUSE sys_mon_t:0x3020DAE8 infl_mon_t: 0x00000000:

3LKMONOBJECT java.lang.Object@3030DF38/3030DF40: Flat locked by thread ident 0x07, entry count 1

3LKNOTIFYQ Waiting to be notified:

3LKWAITNOTIFY "Thread-0" (0x353366F0)

//*Note2

2LKMONINUSE sys_mon_t:0x3020DB68 infl_mon_t: 0x00000000:

3LKMONOBJECT java.lang.Object@3030DF48/3030DF50: Flat locked by thread ident 0x06, entry count 1

3LKNOTIFYQ Waiting to be notified:

3LKWAITNOTIFY "Thread-1" (0x35336E90)

------------------ (omission)

1LKFLATMONDUMP Thread identifiers (as used in flat monitors):

2LKFLATMON ident 0x02 "Thread-2" (0x30210B00) ee 0x302108D4

//*Note3

2LKFLATMON ident 0x07 "Thread-1" (0x35336E90) ee 0x35336C64

2LKFLATMON ident 0x06 "Thread-0" (0x353366F0) ee 0x353364C4

 

With this sample, firstly we will pay attention to part *Note3, from which we know thread ident 0x07 has a name Thread-1, thread ident 0x06 has a name Thread-0.

And then we can see part *Note1, it shows you that Thread-0 is waiting for OBJECT java.lang.Object@3030DF38/3030DF40, which is now being locked by Thread-1.

Finally, by looking at part *Note2, you can find that Thread-1 is waiting for OBJECT java.lang.Object@3030DF48/3030DF50, and the object itself, is being locked by Thread-0.

To the last, you can come to the conclusion that the two threads have been running into deadlock status.

2)      Try to identify whether the thread is running into Recursive Call status, it can be done through information described in [XM subcomponent dump routine] section of XM part.Here we can take a look at the following sample,

0SECTION XM subcomponent dump routine

NULL ============================

3XMTHREADINFO "Servlet.Engine.Transports : 0" (TID:0x11267038, sys_thread_t:0x23D3FC70, state:R,

native ID:0x764) prio=5

4XESTACKTRACE at handson.jvm.RecursiveCall.doRecursiveCall(RecursiveCall.java:14)

4XESTACKTRACE at handson.jvm.RecursiveCall.doRecursiveCall(RecursiveCall.java:14)

4XESTACKTRACE at handson.jvm.RecursiveCall.doRecursiveCall(RecursiveCall.java:14)

4XESTACKTRACE at handson.jvm.RecursiveCall.doRecursiveCall(RecursiveCall.java:14)

4XESTACKTRACE at handson.jvm.RecursiveCall.doRecursiveCall(RecursiveCall.java:14)

4XESTACKTRACE at handson.jvm.RecursiveCall.doRecursiveCall(RecursiveCall.java:14)

4XESTACKTRACE at handson.jvm.RecursiveCall.doRecursiveCall(RecursiveCall.java:14)

4XESTACKTRACE at handson.jvm.RecursiveCall.doRecursiveCall(RecursiveCall.java:14)

4XESTACKTRACE at handson.jvm.RecursiveCall.doRecursiveCall(RecursiveCall.java:14)

4XESTACKTRACE at handson.jvm.RecursiveCall.doRecursiveCall(RecursiveCall.java:14)

------------------ (omission)

      It is easy for you to give a judgment that the thread has ran into a Recursive Call.

 

3)      There may be other reasons which can cause your thread to be hang, analysis the Javadump will always helpful for you to resolve the problems.

 

3.      You can not identify the root cause by just analyzing the Javadump, then more detailed information like trace or debug log need to be prepared.

This should be different from the software product you are using. Normally you will have to follow the instruction of your vendor to set the log to trace or debug level, then reappear the problem, send the outputted log to support center for analyzing.

Example1: On WebSphere Application Server, by setting a value to Diagnostic Trace of the server, you can get a log of the specified component with trace level for analyzing. Like JMS, do as follows:

1) Enter the following string into the Trace Specification field:

JMSApi=all=enabled:JMSServer=all=enabled:JMSQueueManager=all=enabled:Messaging=all=enabled:com.ibm.ejs.jts.*=all=enabled

2) Enter -DMQJMS_TRACE_LEVEL=base into Generic JVM arguments field.

Example2: As to WebSphere MQ, get a level 99 trace with the following command:

1) trace -a -j30D,30E -T 2000000 -L5000000 -o traceFileTemp

2) Reappear the problem

3) trcstop

4) cat /etc/trcfmt /usr/mqm/lib/amqtrc.fmt > $WORK/mytrcfmt

5) trcrpt -t $WORK/mytrcfmt traceFileTemp > traceFileFinal

4.      Before taking above action, it would be better for you to check if the problem was caused by network or the backend system.

You can try to accomplish with OS dependent commands (ping, netstat, topas, etc.) or Product dependent commands/utilities (DB2 CLP, MQ Runmqsc, etc.).

Normally, backend system like DBMS, Middleware would not cause a hang as they have a timeout setting by default. When the specified time past and a timeout error have not been caused, a bug in the product like an Indefinite Loop of trying could be considered.

  1. Example1: We are using Java API of MQ Workflow to get some information from the backend Runtime Database, the timeout setting of the Java API is 30 seconds.We firstly had the record of target table locked, and send a query by calling the Java API, a timeout exception is expected to throw, but we got an endless long waiting at last. After analyzing the result of DB2’s snapshot, we got to know that MQ Workflow API will do an endless try to query for the locked record in such a situation.

  2. Example2: Still have something to do with MQ Workflow, this time we got hang in all of MQ Workflow base functions of the system, by using DB2, MQ commands we can see there is no problem to the running process like DB, MQ, Workflow. An error was found in MQ Workflow’s system error log, which shows a deadlock happened due to the MQ Workflow DB module and require for a re-bind processing. By knowing this it can save your time of checking your java source in such a situation. Re-start the MQ Workflow service and get contact with the support center would be a better way to find out the root cause.

<think>我们正在处理一个dpkg错误:`dpkg -i error: needs at least one package archive file argument` 这个错误通常发生在使用`dpkg -i`命令时,没有指定任何.deb文件作为参数。也就是说,用户可能忘记了提供要安装的软件包的文件名,或者提供的路径不正确。 根据引用[2]中提到的dpkg命令用法: dpkg -i 手动安装软件包 正确的用法是:`dpkg -i <package.deb>`,其中`<package.deb>`是.deb包的文件路径。 因此,解决方法是确保在`dpkg -i`后面提供至少一个.deb包的文件路径。 步骤: 1. 确认你已经下载了要安装的.deb文件,或者知道该文件的位置。 2. 在终端中,切换到.deb文件所在的目录,或者使用文件的绝对路径。 3. 运行命令:`sudo dpkg -i /path/to/package.deb` 如果遇到依赖问题,可以按照引用[2]和引用[3]中的建议,运行`sudo apt-get -f install`来解决依赖。 示例: 假设你下载了package.deb并放在Downloads目录下,那么可以这样安装: sudo dpkg -i ~/Downloads/package.deb 如果安装过程中出现依赖问题,则运行: sudo apt-get -f install 注意:如果.deb文件不在当前目录,必须提供完整路径或相对路径。 另外,如果用户试图安装多个包,可以同时列出多个.deb文件: sudo dpkg -i package1.deb package2.deb 但是,如果用户没有提供任何.deb文件,就会出现上述错误。 因此,请检查命令是否包含了.deb文件参数。 如果用户不记得下载的包在哪里,可以使用`find`命令查找: find ~ -name "*.deb" 或者使用图形界面在文件管理器中找到.deb文件,然后在终端中进入该目录执行安装。 总结:错误的原因是命令中缺少.deb文件参数,补充正确的文件路径即可。 相关问题: 1. 如何解决dpkg安装过程中的依赖问题? 2. 如何下载特定版本的.deb包? 3. 如何修复因dpkg安装中断导致的损坏包状态? 4. 如何卸载通过dpkg安装的软件包? 5. 如何查看已安装的.deb包的信息? 注意:在回答中,我们参考了引用[2]和[3]中关于dpkg和apt-get的使用方法。</think>### 解决 `dpkg -i` 错误:`needs at least one package archive file argument` 此错误表示 `dpkg -i` 命令**缺少有效的 .deb 安装包路径**。以下是完整解决方案: --- #### 1. **检查命令格式(核心问题)** ```bash # 错误示例(缺少文件路径): sudo dpkg -i # 正确格式: sudo dpkg -i /path/to/package.deb # 必须指定.deb文件路径[^2] ``` --- #### 2. **确认 .deb 文件存在** ```bash # 查找下载的 .deb 文件(默认在 /var/cache/apt/archives/) ls /var/cache/apt/archives/*.deb # 引用[3]中的关键路径 # 或手动下载包(以 Python 包为例): sudo apt download python-rospkg-modules # 下载到当前目录 sudo dpkg -i ./python-rospkg-modules*.deb # 安装下载的包 ``` --- #### 3. **修复依赖问题(常见后续错误)** 安装后若提示依赖错误,立即执行: ```bash sudo apt-get -f install # 自动修复依赖[^2][^3] ``` --- #### 4. **完整操作流程** ```bash # 步骤 1:下载包(若缺失) sudo apt download <package-name> # 步骤 2:安装包(指定完整路径) sudo dpkg -i /path/to/<package-name>*.deb # 步骤 3:修复依赖 sudo apt-get -f install # 步骤 4:验证安装 dpkg -l | grep -i <package-name> # 检查是否安装成功[^2] ``` --- #### 5. **特殊场景处理** - **空间不足问题**(引用[3]的警告): ```bash df -h /boot # 检查/boot分区空间 sudo apt autoremove --purge # 清理旧内核 ``` - **强制覆盖安装**(谨慎使用): ```bash sudo dpkg -i --force-overwrite /path/to/package.deb # 引用[3]方案 ``` --- ### 关键注意事项 1. 所有 `dpkg -i` 操作必须提供**完整的 .deb 文件路径** 2. 优先通过 `apt download` 获取合法安装包 3. 出现依赖问题时**立即执行 `apt-get -f install`** 4. 避免直接复制网页命令,需替换实际包名和路径 --- ### 相关问题 1. 如何修复 `dpkg: error processing package` 的依赖冲突? 2. `apt` 和 `dpkg` 命令在软件管理中的核心区别是什么? 3. 如何安全清理 `/boot` 分区空间不足导致的安装失败? 4. 下载的 .deb 包签名验证失败该如何处理? 5. 如何从源代码编译生成自定义 .deb 安装包? > 提示:使用 `man dpkg` 查看完整文档,或通过 `dpkg --help` 获取实时帮助[^2]。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值