From e3701746f3c339944ad80236b6aec5f41e243e7f Mon Sep 17 00:00:00 2001 From: astrubel <66489232+astrubel@users.noreply.github.com> Date: Tue, 9 Jun 2020 19:27:32 +0200 Subject: [PATCH] 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** --- .../jdbc/lock/JdbcLockRegistry.java | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/spring-integration-jdbc/src/main/java/org/springframework/integration/jdbc/lock/JdbcLockRegistry.java b/spring-integration-jdbc/src/main/java/org/springframework/integration/jdbc/lock/JdbcLockRegistry.java index 18a15ae19ac..4a523233696 100644 --- a/spring-integration-jdbc/src/main/java/org/springframework/integration/jdbc/lock/JdbcLockRegistry.java +++ b/spring-integration-jdbc/src/main/java/org/springframework/integration/jdbc/lock/JdbcLockRegistry.java @@ -236,14 +236,20 @@ public void unlock() { 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(); + } } }