Skip to content

Commit 0dd258b

Browse files
committed
Retry on 1020 'Stale read' error from MySQL
Affects issues: - Fixed #4125
1 parent 965669e commit 0dd258b

1 file changed

Lines changed: 2 additions & 1 deletion

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: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,11 @@ private void manageFailure(SQLException statementFail) {
103103

104104
// Retry if deadlock occurs.
105105
int errorCode = statementFail.getErrorCode();
106+
boolean mysqlOutdatedRead = dbType == DBType.MYSQL && errorCode == 1020;
106107
boolean mySQLDeadlock = dbType == DBType.MYSQL && errorCode == 1213;
107108
boolean deadlocked = mySQLDeadlock || statementFail instanceof SQLTransactionRollbackException;
108109
boolean lockWaitTimeout = errorCode == 1205;
109-
if (deadlocked || lockWaitTimeout && attempts < ATTEMPT_LIMIT) {
110+
if (mysqlOutdatedRead || deadlocked || lockWaitTimeout && attempts < ATTEMPT_LIMIT) {
110111
executeTransaction(db); // Recurse to attempt again.
111112
return;
112113
}

0 commit comments

Comments
 (0)