Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make sure Radisson lock is released in case of Redis goes down?

Tags:

java

redis

Radisson lock: I have applied a distributed lock and I am not sure what will happen if Redis goes down in AWS then the lock will never be released or is there a mechanism to do that?

Code snippet:

@Override
@Async
public Future<BaseResponse> someMethodAsync(){
Lock lock = redissonClient.getFairLock(getLockName());
    if(lock.tryLock()){
            //Do something 
            return new AsyncResult<>(resp);
        }finally{
            lock.unlock();
        }
   }
like image 288
John Aladin Avatar asked Sep 17 '25 19:09

John Aladin


1 Answers

LockWatchdogTimeout

Default value: 30000

Lock watchdog timeout in milliseconds. This parameter is only used if the lock has been acquired without leaseTimeout parameter definition. The lock will be expired after lockWatchdogTimeout if watchdog didn't extend it to the next lockWatchdogTimeout time interval. This prevents against infinity locked locks due to Radisson client crush or any other reason when lock can't be released in a proper way.

Read here - https://github.com/redisson/redisson/wiki/2.-Configuration

like image 157
Vikas Meena Avatar answered Sep 20 '25 11:09

Vikas Meena