NutzCN Logo
问答 mysql 事务锁死?
发布于 2810天前 作者 qq_a930202f 1463 次浏览 复制 上一个帖子 下一个帖子
标签:
org.nutz.dao.DaoException: !Nutz SQL Error: ' '
PreparedStatement: 
'INSERT INTO note(id,content) VALUES(?,?) '
CaseMessage=Lock wait timeout exceeded; try restarting transaction
	at org.nutz.dao.impl.sql.run.NutDaoExecutor.exec(NutDaoExecutor.java:104) ~[nutz-1.r.60.jar:na]
	at org.nutz.dao.DaoInterceptorChain.doChain(DaoInterceptorChain.java:66) ~[nutz-1.r.60.jar:na]
	at org.nutz.dao.impl.interceptor.DaoLogInterceptor.filter(DaoLogInterceptor.java:22) ~[nutz-1.r.60.jar:na]
	at org.nutz.dao.DaoInterceptorChain.doChain(DaoInterceptorChain.java:64) ~[nutz-1.r.60.jar:na]
	at org.nutz.dao.DaoInterceptorChain.invoke(DaoInterceptorChain.java:139) ~[nutz-1.r.60.jar:na]
	at org.nutz.dao.impl.sql.run.NutDaoRunner.runCallback(NutDaoRunner.java:158) ~[nutz-1.r.60.jar:na]
	at org.nutz.dao.impl.sql.run.NutDaoRunner._runWithTransaction(NutDaoRunner.java:104) ~[nutz-1.r.60.jar:na]
	at org.nutz.dao.impl.sql.run.NutDaoRunner._run(NutDaoRunner.java:88) ~[nutz-1.r.60.jar:na]
	at org.nutz.dao.impl.sql.run.NutDaoRunner$1.run(NutDaoRunner.java:74) ~[nutz-1.r.60.jar:na]
	at org.nutz.trans.Trans.exec(Trans.java:174) ~[nutz-1.r.60.jar:na]
	at org.nutz.dao.impl.sql.run.NutDaoRunner.run(NutDaoRunner.java:72) ~[nutz-1.r.60.jar:na]
	at org.nutz.dao.impl.DaoSupport.run(DaoSupport.java:240) ~[nutz-1.r.60.jar:na]
	at org.nutz.dao.impl.DaoSupport._exec(DaoSupport.java:248) ~[nutz-1.r.60.jar:na]
	at org.nutz.dao.impl.EntityOperator.exec(EntityOperator.java:50) ~[nutz-1.r.60.jar:na]
	at org.nutz.dao.impl.NutDao.insert(NutDao.java:145) ~[nutz-1.r.60.jar:na]
	at org.nutz.service.EntityService._insert(EntityService.java:351) ~[nutz-1.r.60.jar:na]
	at net.common.service.BaseService.insert_(BaseService.java:168) ~[classes/:na]
	at net.app.service.ApiService.addNote(ApiService.java:63) ~[classes/:na]
	at net.app.service.ApiService$$NUTZAOP._aop_invoke(ApiService.java:2) ~[nutz-1.r.60.jar:na]
	at org.nutz.aop.InterceptorChain.invoke(InterceptorChain.java:77) ~[nutz-1.r.60.jar:na]
	at org.nutz.aop.InterceptorChain.doChain(InterceptorChain.java:57) ~[nutz-1.r.60.jar:na]
	at org.nutz.aop.interceptor.TransactionInterceptor.filter(TransactionInterceptor.java:34) ~[nutz-1.r.60.jar:na]
	at org.nutz.aop.InterceptorChain.doChain(InterceptorChain.java:60) ~[nutz-1.r.60.jar:na]
	at net.app.service.ApiService$$NUTZAOP.addNote(ApiService.java:1) ~[nutz-1.r.60.jar:na]
	at net.app.web.api.ApiModule.note2(ApiModule.java:206) ~[classes/:na]
	at net.app.web.api.ApiModule$$NUTZAOP._aop_invoke(ApiModule.java:1) ~[nutz-1.r.60.jar:na]
	at org.nutz.aop.InterceptorChain.invoke(InterceptorChain.java:77) ~[nutz-1.r.60.jar:na]
	at org.nutz.aop.InterceptorChain.doChain(InterceptorChain.java:57) ~[nutz-1.r.60.jar:na]
	at org.nutz.plugins.slog.aop.SlogAopInterceptor.filter(SlogAopInterceptor.java:68) ~[nutz-plugins-slog-1.r.60.jar:na]
	at org.nutz.aop.InterceptorChain.doChain(InterceptorChain.java:60) ~[nutz-1.r.60.jar:na]
	at net.app.web.api.ApiModule$$NUTZAOP.note2(ApiModule.java:1) ~[nutz-1.r.60.jar:na]
	at net.app.web.api.ApiModule$$FASTCLASS._invoke(ApiModule.java:1) ~[nutz-1.r.60.jar:na]
	at org.nutz.lang.reflect.AbstractFastClass.invoke(AbstractFastClass.java:143) ~[nutz-1.r.60.jar:na]
	at org.nutz.lang.reflect.FastClassFactory.invoke(FastClassFactory.java:67) ~[nutz-1.r.60.jar:na]
	at org.nutz.mvc.impl.processor.MethodInvokeProcessor.process(MethodInvokeProcessor.java:27) ~[nutz-1.r.60.jar:na]
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44) ~[nutz-1.r.60.jar:na]
	at org.nutz.mvc.impl.processor.AdaptorProcessor.process(AdaptorProcessor.java:33) ~[nutz-1.r.60.jar:na]
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44) ~[nutz-1.r.60.jar:na]
	at org.nutz.mvc.impl.processor.ActionFiltersProcessor.process(ActionFiltersProcessor.java:58) ~[nutz-1.r.60.jar:na]
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44) ~[nutz-1.r.60.jar:na]
	at org.nutz.mvc.impl.processor.ModuleProcessor.process(ModuleProcessor.java:123) ~[nutz-1.r.60.jar:na]
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44) ~[nutz-1.r.60.jar:na]
	at org.nutz.mvc.impl.processor.EncodingProcessor.process(EncodingProcessor.java:27) ~[nutz-1.r.60.jar:na]
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44) ~[nutz-1.r.60.jar:na]
	at org.nutz.mvc.impl.processor.UpdateRequestAttributesProcessor.process(UpdateRequestAttributesProcessor.java:15) ~[nutz-1.r.60.jar:na]
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44) ~[nutz-1.r.60.jar:na]
	at net.common.web.processor.LogTimeProcessor.process(LogTimeProcessor.java:23) ~[classes/:na]
	at org.nutz.mvc.impl.NutActionChain.doChain(NutActionChain.java:44) ~[nutz-1.r.60.jar:na]
	at org.nutz.mvc.impl.ActionInvoker.invoke(ActionInvoker.java:67) [nutz-1.r.60.jar:na]
	at org.nutz.mvc.ActionHandler.handle(ActionHandler.java:31) [nutz-1.r.60.jar:na]
	at org.nutz.mvc.NutFilter.doFilter(NutFilter.java:198) [nutz-1.r.60.jar:na]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) [catalina.jar:8.0.33]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) [catalina.jar:8.0.33]
	at org.sitemesh.webapp.contentfilter.ContentBufferingFilter.bufferAndPostProcess(ContentBufferingFilter.java:169) [sitemesh-3.0.1.jar:na]
	at org.sitemesh.webapp.contentfilter.ContentBufferingFilter.doFilter(ContentBufferingFilter.java:126) [sitemesh-3.0.1.jar:na]
	at org.sitemesh.webapp.SiteMeshFilter.doFilter(SiteMeshFilter.java:120) [sitemesh-3.0.1.jar:na]
	at org.sitemesh.config.ConfigurableSiteMeshFilter.doFilter(ConfigurableSiteMeshFilter.java:163) [sitemesh-3.0.1.jar:na]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) [catalina.jar:8.0.33]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) [catalina.jar:8.0.33]
	at com.alibaba.druid.support.http.WebStatFilter.doFilter(WebStatFilter.java:123) [druid-1.0.23.jar:1.0.23]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) [catalina.jar:8.0.33]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) [catalina.jar:8.0.33]
	at org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449) [shiro-web-1.3.1.jar:1.3.1]
	at org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365) [shiro-web-1.3.1.jar:1.3.1]
	at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90) [shiro-core-1.3.1.jar:1.3.1]
	at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83) [shiro-core-1.3.1.jar:1.3.1]
	at org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:383) [shiro-core-1.3.1.jar:1.3.1]
	at org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362) [shiro-web-1.3.1.jar:1.3.1]
	at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125) [shiro-web-1.3.1.jar:1.3.1]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) [catalina.jar:8.0.33]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) [catalina.jar:8.0.33]
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212) [catalina.jar:8.0.33]
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106) [catalina.jar:8.0.33]
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502) [catalina.jar:8.0.33]
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141) [catalina.jar:8.0.33]
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79) [catalina.jar:8.0.33]
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88) [catalina.jar:8.0.33]
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:522) [catalina.jar:8.0.33]
	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1095) [tomcat-coyote.jar:8.0.33]
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:672) [tomcat-coyote.jar:8.0.33]
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1502) [tomcat-coyote.jar:8.0.33]
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1458) [tomcat-coyote.jar:8.0.33]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_121]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_121]
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-util.jar:8.0.33]
	at java.lang.Thread.run(Thread.java:745) [na:1.8.0_121]
Caused by: java.sql.SQLException: Lock wait timeout exceeded; try restarting transaction
	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:998) ~[mysql-connector-java-5.1.35.jar:5.1.35]
	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3835) ~[mysql-connector-java-5.1.35.jar:5.1.35]
	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3771) ~[mysql-connector-java-5.1.35.jar:5.1.35]
	at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2435) ~[mysql-connector-java-5.1.35.jar:5.1.35]
	at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2582) ~[mysql-connector-java-5.1.35.jar:5.1.35]
	at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2535) ~[mysql-connector-java-5.1.35.jar:5.1.35]
	at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1911) ~[mysql-connector-java-5.1.35.jar:5.1.35]
	at com.mysql.jdbc.PreparedStatement.execute(PreparedStatement.java:1203) ~[mysql-connector-java-5.1.35.jar:5.1.35]
	at com.alibaba.druid.filter.FilterChainImpl.preparedStatement_execute(FilterChainImpl.java:2931) ~[druid-1.0.23.jar:1.0.23]
	at com.alibaba.druid.wall.WallFilter.preparedStatement_execute(WallFilter.java:600) ~[druid-1.0.23.jar:1.0.23]
	at com.alibaba.druid.filter.FilterChainImpl.preparedStatement_execute(FilterChainImpl.java:2929) ~[druid-1.0.23.jar:1.0.23]
	at com.alibaba.druid.filter.FilterEventAdapter.preparedStatement_execute(FilterEventAdapter.java:440) ~[druid-1.0.23.jar:1.0.23]
	at com.alibaba.druid.filter.FilterChainImpl.preparedStatement_execute(FilterChainImpl.java:2929) ~[druid-1.0.23.jar:1.0.23]
	at com.alibaba.druid.proxy.jdbc.PreparedStatementProxyImpl.execute(PreparedStatementProxyImpl.java:131) ~[druid-1.0.23.jar:1.0.23]
	at com.alibaba.druid.pool.DruidPooledPreparedStatement.execute(DruidPooledPreparedStatement.java:493) ~[druid-1.0.23.jar:1.0.23]
	at org.nutz.dao.impl.sql.run.NutDaoExecutor._runPreparedStatement(NutDaoExecutor.java:308) ~[nutz-1.r.60.jar:na]
	at org.nutz.dao.impl.sql.run.NutDaoExecutor.exec(NutDaoExecutor.java:90) ~[nutz-1.r.60.jar:na]
	... 85 common frames omitted

6 回复

有其他update语句在执行?

@wendal
InnoDB的表,请教下排查方法。如何避免呢?

一般是查查在这个事务内,对这个表执行过什么sql

事务这段代码很简单

	@Aop(TransAop.READ_COMMITTED)
	public String addNote(Note Note,List<Attachment> attachments){
		String rtn = "";
		
		Note = NoteService.insert_(Note);
		for(Attachment attachment : attachments){
			attachment.setModuleId(Note.getId());
			attachmentService.insert_(attachment);
		}
		syncService.pushDate(Note);
		
		return Note.getId();
	 
	}

syncService.pushDate(Note);是向另一个数据源里面写入数据

去掉事务会正常吗?

偶发现象,之前没出现过,不是很好重现问题。
目前是小范围测试,并发量应该很小。

添加回复
请先登陆
回到顶部