You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
RedissonLock.tryLock() interrupted and keep renew lock #2714
Expected behavior
when tryLock is interrupted, watchdog renew listener is cancelled too
Actual behavior
when tryLock is interrupted, watchdog keeps renewing lock, this makes ifinite lock
Steps to reproduce or test case
private volatile boolean threadTwoScheduled = false; @test
public void lockThenInterruptNotCatchThenBroke() {
RLock lock = redissonClient.getLock("concurrent-test2");
Assert.assertFalse(lock.isLocked());
Thread thread = new Thread(() -> {
threadTwoScheduled = true;
if (!lock.tryLock()) {
return;
}
try {
doBusiness();
} finally {
lock.unlock();
}
});
thread.start();
while(!threadTwoScheduled){}
// let the tcp request be sent out
for (int i = 0; i < 1000; i++) {
new Object();
}
thread.interrupt();
try {
Thread.sleep(45000L); // longer than default watchdog time
} catch (InterruptedException e) {
e.printStackTrace();
}
// lock is still being renewed by watchdog
Assert.assertTrue(lock.isLocked());
}
Redis version
doesn't matter Redisson version
3.11.2 Redisson configuration
Activity
10 remaining items
nomar22 commentedon Jul 19, 2021
probably solved with #3714
mrniko commentedon Jul 19, 2021
@nomar22
I'm afraid no. Still reproducible even with your fix
mrniko commentedon Aug 6, 2021
This happens since watchdog works in Redisson instance scope not in thread.