Skip to content

Commit 18c2067

Browse files
brempuszartembilan
authored andcommitted
GH-2467: JdbcLockReg: retry on TransDataAccessExc
* GH-2467: JdbcLockRegistry should retry on DeadlockLoserDataAccessException Fixes #2467 MySQL 5.7.15 introduced setting `innodb_deadlock_detect` (enabled by default). As a result MySQL JDBC driver throws `DeadlockLoserDataAccessException` when deadlock is detected. `JdbcLockRegistry` doesn't handle it causing lock to be lost. * Retry `doLock()` on data access deadlock instead of loosing the lock * Use TransientDataAccessException instead of derived exceptions (cherry picked from commit 4bb1a61)
1 parent 5dac195 commit 18c2067

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

spring-integration-jdbc/src/main/java/org/springframework/integration/jdbc/lock/JdbcLockRegistry.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,12 @@
2626
import java.util.concurrent.locks.ReentrantLock;
2727

2828
import org.springframework.dao.CannotAcquireLockException;
29-
import org.springframework.dao.CannotSerializeTransactionException;
3029
import org.springframework.dao.DataAccessResourceFailureException;
31-
import org.springframework.dao.QueryTimeoutException;
30+
import org.springframework.dao.TransientDataAccessException;
3231
import org.springframework.integration.support.locks.DefaultLockRegistry;
3332
import org.springframework.integration.support.locks.ExpirableLockRegistry;
3433
import org.springframework.integration.support.locks.LockRegistry;
3534
import org.springframework.integration.util.UUIDConverter;
36-
import org.springframework.transaction.TransactionTimedOutException;
3735
import org.springframework.util.Assert;
3836

3937
/**
@@ -47,6 +45,7 @@
4745
* @author Artem Bilan
4846
* @author Vedran Pavic
4947
* @author Kai Zimmermann
48+
* @author Bartosz Rempuszewski
5049
*
5150
* @since 4.3
5251
*/
@@ -113,7 +112,7 @@ public void lock() {
113112
}
114113
break;
115114
}
116-
catch (CannotSerializeTransactionException | TransactionTimedOutException | QueryTimeoutException e) {
115+
catch (TransientDataAccessException e) {
117116
// try again
118117
}
119118
catch (InterruptedException e) {
@@ -147,7 +146,7 @@ public void lockInterruptibly() throws InterruptedException {
147146
}
148147
break;
149148
}
150-
catch (CannotSerializeTransactionException | TransactionTimedOutException | QueryTimeoutException e) {
149+
catch (TransientDataAccessException e) {
151150
// try again
152151
}
153152
catch (InterruptedException ie) {
@@ -191,7 +190,7 @@ public boolean tryLock(long time, TimeUnit unit) throws InterruptedException {
191190
}
192191
return acquired;
193192
}
194-
catch (CannotSerializeTransactionException | TransactionTimedOutException | QueryTimeoutException e) {
193+
catch (TransientDataAccessException e) {
195194
// try again
196195
}
197196
catch (Exception e) {

0 commit comments

Comments
 (0)