Skip to content

Commit 3a5f783

Browse files
committed
Retry transactions that run into lock wait timeout
Affects issues: - Possibly fixed #3987
1 parent 25efa1d commit 3a5f783

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

  • Plan/common/src/main/java/com/djrapitops/plan/storage/database/transactions

Plan/common/src/main/java/com/djrapitops/plan/storage/database/transactions/Transaction.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,13 @@ private void manageFailure(SQLException statementFail) {
105105
int errorCode = statementFail.getErrorCode();
106106
boolean mySQLDeadlock = dbType == DBType.MYSQL && errorCode == 1213;
107107
boolean deadlocked = mySQLDeadlock || statementFail instanceof SQLTransactionRollbackException;
108-
if (deadlocked && attempts < ATTEMPT_LIMIT) {
108+
boolean lockWaitTimeout = errorCode == 1205;
109+
if (deadlocked || lockWaitTimeout && attempts < ATTEMPT_LIMIT) {
109110
executeTransaction(db); // Recurse to attempt again.
110111
return;
111112
}
112113

113-
if (dbType == DBType.MYSQL && errorCode == 1205) {
114+
if (dbType == DBType.MYSQL && lockWaitTimeout) {
114115
if (!db.isUnderHeavyLoad()) {
115116
db.getLogger().warn("Database appears to be under heavy load. Dropping some unimportant transactions and adding short pauses for next 10 minutes.");
116117
db.getRunnableFactory().create(db::assumeNoMoreHeavyLoad)

0 commit comments

Comments
 (0)