John Aladin
John Aladin

Reputation: 41

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

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();
        }
   }

Upvotes: 4

Views: 3972

Answers (1)

Vikas Meena
Vikas Meena

Reputation: 342

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

Upvotes: 2

Related Questions