Skip to content

Commit 6f262d7

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 # Conflicts: # spring-integration-jdbc/src/main/java/org/springframework/integration/jdbc/lock/JdbcLockRegistry.java
1 parent 81cfa80 commit 6f262d7

File tree

1 file changed

+5
-24
lines changed

1 file changed

+5
-24
lines changed

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

+5-24
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
*/
@@ -125,15 +124,9 @@ public void lock() {
125124
}
126125
break;
127126
}
128-
catch (CannotSerializeTransactionException e) {
127+
catch (TransientDataAccessException e) {
129128
// try again
130129
}
131-
catch (TransactionTimedOutException e) {
132-
// try again
133-
}
134-
catch (QueryTimeoutException e) {
135-
// try again
136-
}
137130
catch (InterruptedException e) {
138131
/*
139132
* This method must be uninterruptible so catch and ignore
@@ -165,15 +158,9 @@ public void lockInterruptibly() throws InterruptedException {
165158
}
166159
break;
167160
}
168-
catch (CannotSerializeTransactionException e) {
169-
// try again
170-
}
171-
catch (TransactionTimedOutException e) {
161+
catch (TransientDataAccessException e) {
172162
// try again
173163
}
174-
catch (QueryTimeoutException e) {
175-
// try again
176-
}
177164
catch (InterruptedException ie) {
178165
this.delegate.unlock();
179166
Thread.currentThread().interrupt();
@@ -215,15 +202,9 @@ public boolean tryLock(long time, TimeUnit unit) throws InterruptedException {
215202
}
216203
return acquired;
217204
}
218-
catch (CannotSerializeTransactionException e) {
219-
// try again
220-
}
221-
catch (TransactionTimedOutException e) {
205+
catch (TransientDataAccessException e) {
222206
// try again
223207
}
224-
catch (QueryTimeoutException e) {
225-
// try again
226-
}
227208
catch (Exception e) {
228209
this.delegate.unlock();
229210
rethrowAsLockException(e);

0 commit comments

Comments
 (0)