Skip to content

RedissonLock.tryLock() interrupted and keep renew lock #2714

@fan0916

Description

@fan0916

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

added this to the 3.12.6 milestone on Apr 22, 2020
modified the milestones: 3.13.0, 3.13.1 on May 22, 2020
modified the milestones: 3.13.1, 3.13.2 on Jun 7, 2020
modified the milestones: 3.13.2, 3.13.3 on Jul 3, 2020
modified the milestones: 3.13.3, 3.13.4 on Aug 6, 2020
modified the milestones: 3.13.4, 3.13.5 on Sep 4, 2020
modified the milestones: 3.13.5, 3.13.6 on Sep 30, 2020
modified the milestones: 3.13.6, 3.13.7 on Oct 14, 2020

28 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

      Development

      Participants

      @mrniko@nomar22@fan0916

      Issue actions

        RedissonLock.tryLock() interrupted and keep renew lock · Issue #2714 · redisson/redisson