GH-3294: Retry JdbcLock.unlock for TransDataAccEx

Fixes https://github.com/spring-projects/spring-integration/issues/3294

A `DeadlockLoserDataAccessException` occurs at `JdbcLockRegistry$JdbcLock.unlock()` - 
better to retry like in the `lock()`

**Cherry-pick to 5.3.x, 5.2.x, 5.1.x & 4.3.x**
This commit is contained in:
astrubel
2020-06-09 19:27:32 +02:00
committed by artembilan
parent d7549a94ae
commit e3701746f3

View File

@@ -236,14 +236,20 @@ public class JdbcLockRegistry implements ExpirableLockRegistry {
this.delegate.unlock();
return;
}
try {
this.mutex.delete(this.path);
}
catch (Exception e) {
throw new DataAccessResourceFailureException("Failed to release mutex at " + this.path, e);
}
finally {
this.delegate.unlock();
while (true) {
try {
this.mutex.delete(this.path);
return;
}
catch (TransientDataAccessException e) {
// try again
}
catch (Exception e) {
throw new DataAccessResourceFailureException("Failed to release mutex at " + this.path, e);
}
finally {
this.delegate.unlock();
}
}
}