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
This commit is contained in:
brempusz
2018-06-07 18:56:33 +02:00
committed by Artem Bilan
parent 81cfa805ae
commit 6f262d7d21

View File

@@ -26,14 +26,12 @@ import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import org.springframework.dao.CannotAcquireLockException;
import org.springframework.dao.CannotSerializeTransactionException;
import org.springframework.dao.DataAccessResourceFailureException;
import org.springframework.dao.QueryTimeoutException;
import org.springframework.dao.TransientDataAccessException;
import org.springframework.integration.support.locks.DefaultLockRegistry;
import org.springframework.integration.support.locks.ExpirableLockRegistry;
import org.springframework.integration.support.locks.LockRegistry;
import org.springframework.integration.util.UUIDConverter;
import org.springframework.transaction.TransactionTimedOutException;
import org.springframework.util.Assert;
/**
@@ -47,6 +45,7 @@ import org.springframework.util.Assert;
* @author Artem Bilan
* @author Vedran Pavic
* @author Kai Zimmermann
* @author Bartosz Rempuszewski
*
* @since 4.3
*/
@@ -125,15 +124,9 @@ public class JdbcLockRegistry implements ExpirableLockRegistry {
}
break;
}
catch (CannotSerializeTransactionException e) {
catch (TransientDataAccessException e) {
// try again
}
catch (TransactionTimedOutException e) {
// try again
}
catch (QueryTimeoutException e) {
// try again
}
catch (InterruptedException e) {
/*
* This method must be uninterruptible so catch and ignore
@@ -165,15 +158,9 @@ public class JdbcLockRegistry implements ExpirableLockRegistry {
}
break;
}
catch (CannotSerializeTransactionException e) {
catch (TransientDataAccessException e) {
// try again
}
catch (TransactionTimedOutException e) {
// try again
}
catch (QueryTimeoutException e) {
// try again
}
catch (InterruptedException ie) {
this.delegate.unlock();
Thread.currentThread().interrupt();
@@ -215,15 +202,9 @@ public class JdbcLockRegistry implements ExpirableLockRegistry {
}
return acquired;
}
catch (CannotSerializeTransactionException e) {
catch (TransientDataAccessException e) {
// try again
}
catch (TransactionTimedOutException e) {
// try again
}
catch (QueryTimeoutException e) {
// try again
}
catch (Exception e) {
this.delegate.unlock();
rethrowAsLockException(e);