Skip to content

Commit 7b40488

Browse files
astrubelartembilan
authored andcommitted
GH-3294: Retry JdbcLock.unlock for TransDataAccEx
Fixes #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**
1 parent 05ceee3 commit 7b40488

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

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

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -234,14 +234,20 @@ public void unlock() {
234234
this.delegate.unlock();
235235
return;
236236
}
237-
try {
238-
this.mutex.delete(this.path);
239-
}
240-
catch (Exception e) {
241-
throw new DataAccessResourceFailureException("Failed to release mutex at " + this.path, e);
242-
}
243-
finally {
244-
this.delegate.unlock();
237+
while (true) {
238+
try {
239+
this.mutex.delete(this.path);
240+
return;
241+
}
242+
catch (TransientDataAccessException e) {
243+
// try again
244+
}
245+
catch (Exception e) {
246+
throw new DataAccessResourceFailureException("Failed to release mutex at " + this.path, e);
247+
}
248+
finally {
249+
this.delegate.unlock();
250+
}
245251
}
246252
}
247253

0 commit comments

Comments
 (0)