首页 > 其他分享 >多线程锁等待超时解决方案

多线程锁等待超时解决方案

时间:2022-12-02 09:55:12浏览次数:37  
标签:超时 java invoke 解决方案 springframework concurrent org 多线程 com

java.util.concurrent.ExecutionException: org.springframework.dao.CannotAcquireLockException: 
### Error updating database.  Cause: com.mysql.cj.jdbc.exceptions.MySQLTransactionRollbackException: Lock wait timeout exceeded; try restarting transaction
### The error may exist in com/manageSystem/project/lt/mapper/LtThreeCenterTeamMapper.java (best guess)
### The error may involve defaultParameterMap
### The error occurred while setting parameters
### SQL: DELETE FROM lt_three_center_team
### Cause: com.mysql.cj.jdbc.exceptions.MySQLTransactionRollbackException: Lock wait timeout exceeded; try restarting transaction
; Lock wait timeout exceeded; try restarting transaction; nested exception is com.mysql.cj.jdbc.exceptions.MySQLTransactionRollbackException: Lock wait timeout exceeded; try restarting transaction
    at java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:357)
    at java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1895)
    at com.manageSystem.project.lt.service.impl.LtThreeCenterTeamServiceImpl.generate(LtThreeCenterTeamServiceImpl.java:111)
    at com.manageSystem.project.lt.service.impl.LtThreeCenterTeamServiceImpl$$FastClassBySpringCGLIB$$5b49d7fe.invoke(<generated>)
    at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:779)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:750)
    at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:123)
    at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:388)
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:119)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:750)
    at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:692)
    at com.manageSystem.project.lt.service.impl.LtThreeCenterTeamServiceImpl$$EnhancerBySpringCGLIB$$364348a6.generate(<generated>)
    at com.manageSystem.framework.task.StatisticTask.generateThreeCenterTeam(StatisticTask.java:437)
    at com.manageSystem.framework.task.StatisticTask$$FastClassBySpringCGLIB$$e05643a9.invoke(<generated>)
    at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
    at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:688)
    at com.manageSystem.framework.task.StatisticTask$$EnhancerBySpringCGLIB$$d7f796b1.generateThreeCenterTeam(<generated>)
    at sun.reflect.GeneratedMethodAccessor459.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:84)
    at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54)
    at org.springframework.scheduling.concurrent.ReschedulingRunnable.run(ReschedulingRunnable.java:95)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run$$$capture(FutureTask.java:266)
    at java.util.concurrent.FutureTask.run(FutureTask.java)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
Caused by: org.springframework.dao.CannotAcquireLockException: 
### Error updating database.  Cause: com.mysql.cj.jdbc.exceptions.MySQLTransactionRollbackException: Lock wait timeout exceeded; try restarting transaction
### The error may exist in com/manageSystem/project/lt/mapper/LtThreeCenterTeamMapper.java (best guess)
### The error may involve defaultParameterMap
### The error occurred while setting parameters
### SQL: DELETE FROM lt_three_center_team
### Cause: com.mysql.cj.jdbc.exceptions.MySQLTransactionRollbackException: Lock wait timeout exceeded; try restarting transaction
; Lock wait timeout exceeded; try restarting transaction; nested exception is com.mysql.cj.jdbc.exceptions.MySQLTransactionRollbackException: Lock wait timeout exceeded; try restarting transaction
    at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:267)
    at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:70)
    at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:88)
    at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:440)
    at com.sun.proxy.$Proxy135.delete(Unknown Source)
    at org.mybatis.spring.SqlSessionTemplate.delete(SqlSessionTemplate.java:303)
    at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.execute(MybatisMapperMethod.java:70)
    at com.baomidou.mybatisplus.core.override.MybatisMapperProxy$PlainMethodInvoker.invoke(MybatisMapperProxy.java:148)
    at com.baomidou.mybatisplus.core.override.MybatisMapperProxy.invoke(MybatisMapperProxy.java:89)
    at com.sun.proxy.$Proxy201.delete(Unknown Source)
    at com.manageSystem.project.lt.service.impl.LtThreeCenterTeamServiceImpl.lambda$generate$0(LtThreeCenterTeamServiceImpl.java:106)
    at java.util.concurrent.CompletableFuture$AsyncSupply.run$$$capture(CompletableFuture.java:1590)
    at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java)
    at java.util.concurrent.CompletableFuture$AsyncSupply.exec(CompletableFuture.java:1582)
    at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
    at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
    at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
    at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)
Caused by: com.mysql.cj.jdbc.exceptions.MySQLTransactionRollbackException: Lock wait timeout exceeded; try restarting transaction
    at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:123)
    at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122)
    at com.mysql.cj.jdbc.ClientPreparedStatement.executeInternal(ClientPreparedStatement.java:953)
    at com.mysql.cj.jdbc.ClientPreparedStatement.execute(ClientPreparedStatement.java:370)
    at com.alibaba.druid.filter.FilterChainImpl.preparedStatement_execute(FilterChainImpl.java:3461)
    at com.alibaba.druid.filter.FilterEventAdapter.preparedStatement_execute(FilterEventAdapter.java:440)
    at com.alibaba.druid.filter.FilterChainImpl.preparedStatement_execute(FilterChainImpl.java:3459)
    at com.alibaba.druid.proxy.jdbc.PreparedStatementProxyImpl.execute(PreparedStatementProxyImpl.java:167)
    at com.alibaba.druid.pool.DruidPooledPreparedStatement.execute(DruidPooledPreparedStatement.java:497)
    at org.apache.ibatis.executor.statement.PreparedStatementHandler.update(PreparedStatementHandler.java:47)
    at org.apache.ibatis.executor.statement.RoutingStatementHandler.update(RoutingStatementHandler.java:74)
    at com.baomidou.mybatisplus.core.executor.MybatisSimpleExecutor.doUpdate(MybatisSimpleExecutor.java:56)
    at org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:117)
    at com.baomidou.mybatisplus.core.executor.MybatisCachingExecutor.update(MybatisCachingExecutor.java:85)
    at sun.reflect.GeneratedMethodAccessor208.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:63)
    at com.sun.proxy.$Proxy468.update(Unknown Source)
    at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:197)
    at org.apache.ibatis.session.defaults.DefaultSqlSession.delete(DefaultSqlSession.java:212)
    at sun.reflect.GeneratedMethodAccessor269.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:426)
    ... 14 more
耗时------------------51031

我的前同事使用@Asnc注解删除10多页的表,再插入数据,其他线程对这张表也有操作。在删除这张表时耗时比较长,其他线程只能处于等待状态,数据库就会出现超时的异常。针对以上分析,我提出的解决方案是,使用多线程分批删除数据,然后再插入数据

可能这样会解决这个遗留很久的问题。我正在实践中。

 

标签:超时,java,invoke,解决方案,springframework,concurrent,org,多线程,com
From: https://www.cnblogs.com/wangweiip/p/16943471.html

相关文章

  • String的hashCode可能会返回负数&解决方案
    String的hashCode可能会返回负数&解决方案产生原因:可以查看StringhashCode()的源码,会发现,它使用的是int类型,这个时候如果字符串过长,则会溢出publicinthashCode......
  • 多线程加锁之后不就是单线程了吗
    突然灵机一动想到:多线程加锁之后不就是单线程了吗,其实在学java的时候老师应该有讲过,但是都忘记了。Q: 多线程lock之后不就是单线程了吗?答:lock并不需要锁定所有的操作......
  • jeecg问题解决方案
    1.jeecg数据库脚本问题  注意:jeecg3.5.2之前版本,不需要数据库脚本,程序会自动初始化数据库。从3.5.2+开始,需要手工执行SQL脚本,初始化数据库。  2.  Eclipse内存溢......
  • 工业物联网案例:注塑机PLC联网监控解决方案
    注塑机注塑机又名注射成型机,将热塑性塑料或热固性塑料利用塑料成型模具制成各种形状的塑料制品的主要成型设备,有立式、卧式、全电式等不同种类。注塑机可以制造拥有复杂外形......
  • Centos SSL 过期问题三个解决方案
    解决方案地址: http://www.megaleecher.net/SSL_Certificate_Verification_Error_in_Linux#axzz3P9axfRfp 返回错误信息如下:fatal:unabletoaccess'https://github.co......
  • 多线程-基础
    1、继承Thread类​继承Thread必须重写run方法,(具体业务执行方法,需要执行的业务方法,定义在此方法中),注意此方法是线程启动后线程自动调用的;案例publicclassMyThreadext......
  • C#通过UrlReWrite配置重定向以及代理Proxy中的超时请求
    项目使用UrlReWrite重定向功能,同时也设置了代理,但是IIS的默认是120秒,高级设置里的连接超时也设置7200秒,但是网站在导出excel的时候,还是出现502-web服务器在作为网关或代理服......
  • 这一次,火山引擎VeDI想跟你聊聊突破增长瓶颈的两个解决方案
    更多技术交流、求职机会,欢迎关注字节跳动数据平台微信公众号,回复【1】进入官方交流群国内消费市场正在发生一些新变化。近日,由中国人民大学国家发展与战略研究院、经济学院......
  • Oracle RAC集群监听Not All Endpoints Registered异常及解决方案
    查看集群状态,就发现NotAllEndpointsRegistered报错,如下所示[grid@erpdb1~]$crsctlstatres-t---------------------------------------------------------------......
  • vite 运行或打包出现内存溢出的解决方案
    在使用vite运行或打包时出现了内存耗尽的报错viteVUEnpmrunbuild报错npmERR!codeELIFECYCLEnpmERR!errno134内存溢出  node内存泄漏耗尽解决方法:在使......