Git Product home page Git Product logo

Comments (7)

mrniko avatar mrniko commented on September 26, 2024 1

Fixed. Thanks for report

from redisson.

victornoel avatar victornoel commented on September 26, 2024

A variation on the example given above is:

RedissonClient redisson = Redisson.create(config);
RLock lock = redisson.getLock("test-lock:1");
lock.lock(10, TimeUnit.SECONDS);
Thread.sleep(5000);
lock.lock(10, TimeUnit.SECONDS);
lock.unlock();
System.out.println(lock.remainTimeToLive());

Should the remainTimeToLive be 10 seconds or 5 seconds?

Another one:

RedissonClient redisson = Redisson.create(config);
RLock lock = redisson.getLock("test-lock:1");
lock.lock(10, TimeUnit.SECONDS);
lock.lock(5, TimeUnit.SECONDS);
lock.unlock();
System.out.println(lock.remainTimeToLive());

Should the remainTimeToLive be 10 seconds or 5 seconds?

from redisson.

victornoel avatar victornoel commented on September 26, 2024

Hi @mrniko, do you know if there is some plan to fix this in a next patch version? Or is there something I can do to help?

from redisson.

mrniko avatar mrniko commented on September 26, 2024

A variation on the example given above is:

RedissonClient redisson = Redisson.create(config);
RLock lock = redisson.getLock("test-lock:1");
lock.lock(10, TimeUnit.SECONDS);
Thread.sleep(5000);
lock.lock(10, TimeUnit.SECONDS);
lock.unlock();
System.out.println(lock.remainTimeToLive());

Should the remainTimeToLive be 10 seconds or 5 seconds?

Another one:

RedissonClient redisson = Redisson.create(config);
RLock lock = redisson.getLock("test-lock:1");
lock.lock(10, TimeUnit.SECONDS);
lock.lock(5, TimeUnit.SECONDS);
lock.unlock();
System.out.println(lock.remainTimeToLive());

Should the remainTimeToLive be 10 seconds or 5 seconds?

first example is about 10 seconds. Second example is about 5 seconds. I have checked your examples. Results are correct.

from redisson.

victornoel avatar victornoel commented on September 26, 2024

I have checked your examples. Results are correct.

Ok, so you didn't reproduce the problem I was experiencing where lock, lock, unlock would result with a time to live to be the default 30seconds instead?

I will check again with latest version and close this if it's all good. Thank you for looking into it.

from redisson.

victornoel avatar victornoel commented on September 26, 2024

So, yes, indeed, it works as expected, so I'm not sure what happens in my particular environment (because I have built abstractions on top of Redisson and I had tests that are now failing with 3.19.2+).

I will close this ticket then and reopen one if needed. Sorry again for the noise :)

from redisson.

victornoel avatar victornoel commented on September 26, 2024

Well, that was fast, actually the bug is really there, the repro is the same as in the description but with a twist:

RedissonClient redisson = Redisson.create(config);
RLock lock = redisson.getLock("test-lock:1");
lock.lock(10, TimeUnit.SECONDS);
lock.lock(10, TimeUnit.SECONDS);
lock.lock(10, TimeUnit.SECONDS);
lock.unlock();
lock.unlock();
System.out.println(lock.remainTimeToLive()); // prints something close to the config default of 30 000

from redisson.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.