当前位置:   article > 正文

Lock wait timeout exceeded; try restarting transaction

lock wait timeout exceeded; try restarting transaction

锁等待超时 Lock wait timeout exceeded; try restarting transaction,是当前事务在等待其它事务释放锁资源造成的

  1. ### Cause: java.sql.SQLException: Lock wait timeout exceeded; try restarting transaction
  2. ; SQL []; Lock wait timeout exceeded; try restarting transaction; nested exception is java.sql.SQLException: Lock wait timeout exceeded; try restarting transaction
  3. at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:259)
  4. at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:73)
  5. at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:74)
  6. at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:399)
  7. at com.sun.proxy.$Proxy30.update(Unknown Source)
  8. at org.mybatis.spring.SqlSessionTemplate.update(SqlSessionTemplate.java:269)
  9. at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:54)
  10. at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:52)
  11. at com.sun.proxy.$Proxy46.updateSearchCountBydealStatus(Unknown Source)
  12. at com.autoserve.weijinrong.loan.modules.plan.service.ProjectPlanService.timingQueryBatchReceivables(ProjectPlanService.java:544)
  13. at com.autoserve.weijinrong.loan.modules.plan.service.ProjectPlanService$$FastClassBySpringCGLIB$$a5d3cf75.invoke(<generated>)
  14. at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
  15. at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:718)
  16. at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
  17. at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)
  18. at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281)
  19. at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
  20. at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
  21. at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:653)
  22. at com.autoserve.weijinrong.loan.modules.plan.service.ProjectPlanService$$EnhancerBySpringCGLIB$$1f8f4733.timingQueryBatchReceivables(<generated>)
  23. at com.autoserve.weijinrong.loan.modules.plan.service.ProjectPlanService$$FastClassBySpringCGLIB$$a5d3cf75.invoke(<generated>)
  24. at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
  25. at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:718)
  26. at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
  27. at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)
  28. at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281)
  29. at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
  30. at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
  31. at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:653)
  32. at com.autoserve.weijinrong.loan.modules.plan.service.ProjectPlanService$$EnhancerBySpringCGLIB$$2301f689.timingQueryBatchReceivables(<generated>)
  33. at com.autoserve.weijinrong.loan.Task.AutoPayTask.timingQueryBatchReceivables(AutoPayTask.java:161)
  34. at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  35. at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
  36. at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
  37. at java.lang.reflect.Method.invoke(Unknown Source)
  38. at org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:65)
  39. at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54)
  40. at org.springframework.scheduling.concurrent.ReschedulingRunnable.run(ReschedulingRunnable.java:81)
  41. at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
  42. at java.util.concurrent.FutureTask.run(Unknown Source)
  43. at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(Unknown Source)
  44. at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source)
  45. at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
  46. at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
  47. at java.lang.Thread.run(Unknown Source)
  48. Caused by: java.sql.SQLException: Lock wait timeout exceeded; try restarting transaction
  49. at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1084)
  50. at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4232)
  51. at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4164)
  52. at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2615)
  53. at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2776)
  54. at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2838)
  55. at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2082)
  56. at com.mysql.jdbc.PreparedStatement.execute(PreparedStatement.java:1307)
  57. at com.alibaba.druid.filter.FilterChainImpl.preparedStatement_execute(FilterChainImpl.java:2931)
  58. at com.alibaba.druid.filter.FilterEventAdapter.preparedStatement_execute(FilterEventAdapter.java:440)
  59. at com.alibaba.druid.filter.FilterChainImpl.preparedStatement_execute(FilterChainImpl.java:2929)
  60. at com.alibaba.druid.proxy.jdbc.PreparedStatementProxyImpl.execute(PreparedStatementProxyImpl.java:131)
  61. at com.alibaba.druid.pool.DruidPooledPreparedStatement.execute(DruidPooledPreparedStatement.java:493)
  62. at sun.reflect.GeneratedMethodAccessor190.invoke(Unknown Source)
  63. at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
  64. at java.lang.reflect.Method.invoke(Unknown Source)
  65. at org.apache.ibatis.logging.jdbc.PreparedStatementLogger.invoke(PreparedStatementLogger.java:62)
  66. at com.sun.proxy.$Proxy37.execute(Unknown Source)
  67. at org.apache.ibatis.executor.statement.PreparedStatementHandler.update(PreparedStatementHandler.java:44)
  68. at org.apache.ibatis.executor.statement.RoutingStatementHandler.update(RoutingStatementHandler.java:69)
  69. at org.apache.ibatis.executor.SimpleExecutor.doUpdate(SimpleExecutor.java:48)
  70. at org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:105)
  71. at org.apache.ibatis.executor.CachingExecutor.update(CachingExecutor.java:71)
  72. at sun.reflect.GeneratedMethodAccessor264.invoke(Unknown Source)
  73. at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
  74. at java.lang.reflect.Method.invoke(Unknown Source)
  75. at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:62)
  76. at com.sun.proxy.$Proxy150.update(Unknown Source)
  77. at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:152)
  78. at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  79. at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
  80. at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
  81. at java.lang.reflect.Method.invoke(Unknown Source)
  82. at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:386)
  83. ... 41 more

解决办法

1、数据库中执行如下sql,查看当前数据库的线程情况:

show full PROCESSLIST

2、再到 INNODB_TRX 事务表中查看,看 trx_mysql_thread_id 是否在 show full processlist 里面的 sleep 线程中(
INNODB_TRX 表的 trx_mysql_thread_id  字段对应 show full processlist 中的Id);如果在,就说明这个 sleep 的线程事务一直没有 commit 或者 rollback,而是卡住了,需要我们手动删除。

select * from information_schema.innodb_trx

3、将找到的 trx_mysql_thread_id 手动删除,即可

如上图,trx_mysql_thread_id 为 1816

kill  1816

 

声明:本文内容由网友自发贡献,转载请注明出处:【wpsshop】
推荐阅读
相关标签
  

闽ICP备14008679号