Deadlock
szuliguo opened this issue · comments
我使用的是duic 2.2.2版本和MySQL 部署,但是在启动日志中会出现死锁的提示。如下:
2019-02-16 16:27:53,729 ERROR reactor.core.scheduler.Schedulers - Scheduler worker in group main failed with an uncaught exception
reactor.core.Exceptions$ErrorCallbackNotImplemented: org.springframework.dao.DeadlockLoserDataAccessException: PreparedStatementCallback; SQL [DELETE FROM DUIC_SERVER WHERE ACTIVE_AT<=?(conn=109) Deadlock found when trying to get lock; try restarting transaction; nested exception is java.sql.SQLTransactionRollbackException: (conn=109) Deadlock found when trying to get lock; try restarting transaction
Caused by: org.springframework.dao.DeadlockLoserDataAccessException: PreparedStatementCallback; SQL [DELETE FROM DUIC_SERVER WHERE ACTIVE_AT<=?(conn=109) Deadlock found when trying to get lock; try restarting transaction; nested exception is java.sql.SQLTransactionRollbackException: (conn=109) Deadlock found when trying to get lock; try restarting transaction
at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:266)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:72)
at org.springframework.jdbc.core.JdbcTemplate.translateException(JdbcTemplate.java:1402)
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:620)
at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:850)
at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:871)
at org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate.update(NamedParameterJdbcTemplate.java:317)
at org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate.update(NamedParameterJdbcTemplate.java:322)
at io.zhudy.duic.repository.impl.MySQLServerRepository$clean$1$n$1.doInTransaction(MySQLServerRepository.kt:93)
at io.zhudy.duic.repository.impl.MySQLServerRepository$clean$1$n$1.doInTransaction(MySQLServerRepository.kt:33)
at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:140)
at io.zhudy.duic.repository.impl.MySQLServerRepository$clean$1.accept(MySQLServerRepository.kt:92)
at io.zhudy.duic.repository.impl.MySQLServerRepository$clean$1.accept(MySQLServerRepository.kt:33)
at reactor.core.publisher.MonoCreate.subscribe(MonoCreate.java:54)
at reactor.core.publisher.MonoOnAssembly.subscribe(MonoOnAssembly.java:76)
at reactor.core.publisher.Mono.subscribe(Mono.java:3080)
at reactor.core.publisher.MonoSubscribeOn$SubscribeOnSubscriber.run(MonoSubscribeOn.java:123)
at reactor.core.scheduler.WorkerTask.call(WorkerTask.java:84)
at reactor.core.scheduler.WorkerTask.call(WorkerTask.java:37)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
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)
Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException:
Assembly trace from producer [reactor.core.publisher.MonoCreate] :
reactor.core.publisher.Mono.create(Mono.java:172)
io.zhudy.duic.repository.impl.MySQLServerRepository.clean(MySQLServerRepository.kt:91)
io.zhudy.duic.service.ServerService.clockPing(ServerService.kt:77)
org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:84)
org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54)
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
Error has been observed by the following operator(s):
|_ Mono.create(MySQLServerRepository.kt:91)
|_ Mono.subscribeOn(ServerService.kt:78)
Caused by: java.sql.SQLTransactionRollbackException: (conn=109) Deadlock found when trying to get lock; try restarting transaction
at org.mariadb.jdbc.internal.util.exceptions.ExceptionMapper.get(ExceptionMapper.java:179)
at org.mariadb.jdbc.internal.util.exceptions.ExceptionMapper.getException(ExceptionMapper.java:110)
at org.mariadb.jdbc.MariaDbStatement.executeExceptionEpilogue(MariaDbStatement.java:228)
at org.mariadb.jdbc.MariaDbPreparedStatementServer.executeInternal(MariaDbPreparedStatementServer.java:382)
at org.mariadb.jdbc.MariaDbPreparedStatementServer.execute(MariaDbPreparedStatementServer.java:344)
at org.mariadb.jdbc.MariaDbPreparedStatementServer.executeUpdate(MariaDbPreparedStatementServer.java:331)
at com.zaxxer.hikari.pool.ProxyPreparedStatement.executeUpdate(ProxyPreparedStatement.java:61)
at com.zaxxer.hikari.pool.HikariProxyPreparedStatement.executeUpdate(HikariProxyPreparedStatement.java)
at org.springframework.jdbc.core.JdbcTemplate.lambda$update$0(JdbcTemplate.java:855)
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:605)
... 21 common frames omitted
Caused by: java.sql.SQLException: Deadlock found when trying to get lock; try restarting transaction
Query is: DELETE FROM DUIC_SERVER WHERE ACTIVE_AT<=?, parameters ['2019-02-16 16:25:53.725']
at org.mariadb.jdbc.internal.util.LogQueryTool.exceptionWithQuery(LogQueryTool.java:153)
at org.mariadb.jdbc.internal.protocol.AbstractQueryProtocol.executePreparedQuery(AbstractQueryProtocol.java:971)
at org.mariadb.jdbc.MariaDbPreparedStatementServer.executeInternal(MariaDbPreparedStatementServer.java:376)
... 27 common frames omitted
这是一个 bug 我会尽快修复它,这可能需要 1-2 周的时间。