Skip to content

Commit e370174

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 d7549a9 commit e370174

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
@@ -236,14 +236,20 @@ public void unlock() {
236236
this.delegate.unlock();
237237
return;
238238
}
239-
try {
240-
this.mutex.delete(this.path);
241-
}
242-
catch (Exception e) {
243-
throw new DataAccessResourceFailureException("Failed to release mutex at " + this.path, e);
244-
}
245-
finally {
246-
this.delegate.unlock();
239+
while (true) {
240+
try {
241+
this.mutex.delete(this.path);
242+
return;
243+
}
244+
catch (TransientDataAccessException e) {
245+
// try again
246+
}
247+
catch (Exception e) {
248+
throw new DataAccessResourceFailureException("Failed to release mutex at " + this.path, e);
249+
}
250+
finally {
251+
this.delegate.unlock();
252+
}
247253
}
248254
}
249255

0 commit comments

Comments
 (0)