记录一次死锁排查过程

同一条数据,两个更新操作,不在一个事务里面,导致死锁,后台日志到了一个update语句就卡住了,也没有报错,线上环境是用的linux服务器,

      at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.jav
a:4798)
        at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:
4875)
        - locked <0x00000006df01ee80> (a oracle.jdbc.driver.T4CConnection)
        at oracle.jdbc.driver.OraclePreparedStatementWrapper.executeUpdate(OraclePreparedStatemen
tWrapper.java:1361)
        at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedSt
atement.java:105)
        at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedSt
atement.java:105)
        at com.epxing.frame.database.BasicDBContext.update(BasicDBContext.java:993)
        at com.epxing.frame.database.BasicDBContext.update(BasicDBContext.java:927)
        at com.epxing.frame.database.BasicDBContext.update(BasicDBContext.java:823)
        at com.epxing.frame.bo.BasicEntityBO.update(BasicEntityBO.java:334)
        at com.epxing.frame.bo.BasicEntityBO.update(BasicEntityBO.java:305)
        at com.epxing.project.xajtdx.register.bo.StaffRegisterBO_XAJTDX.handleEvent(StaffRegister
BO_XAJTDX.java:555)
        at com.epxing.frame.process.util.ProcessUtil.processEvent(ProcessUtil.java:141)
        at com.epxing.frame.process.bo.ProcessBO.next(ProcessBO.java:159)
        at com.epxing.project.xajtdx.process.bo.ProcessBO_XAJTDX.handleTask(ProcessBO_XAJTDX.java
:121)
        at com.epxing.frame.process.bo.ProcessBO.handleTask(ProcessBO.java:206)
        at com.epxing.project.xajtdx.staff.action.StaffAction_XAJTDX.updateAndEntityHandleTask(St
affAction_XAJTDX.java:175)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at com.epxing.frame.control.SimpleAction.processAction(SimpleAction.java:179)
        at com.epxing.frame.control.SimpleAction.process(SimpleAction.java:132)
        at com.epxing.frame.control.FrameServlet.service(FrameServlet.java:55)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:764)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChai
n.java:232)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:1
67)

解决办法:

1、使用jstack工具,首先用ps -ef|grep java 查询当前的java进程,

ps -ef|grep java

2、使用 jstack -l [进程号]>lock.jstack 命令将日志导出到lock.jstack文件中

jstack -l 1111 >lock.jstack

3、使用less命令查询lock.jstack文件,找到对应报错地方,打开文件一直翻,直到找到 "Found one Java-level deadlock:"关键字,就可以找对应的代码的位置了

你可能感兴趣的:(java)