Add Redis lock periodic renewal
Although `RenewableLockRegistry` provides a renew interface, it is inconvenient for users. Developers hope to have a lock that can be automatically renewed. On the one hand, it can avoid subsequent failures caused by locks that will not expire when abnormal exits, and on the other hand, it can avoid unlock failures caused by lock expired. * Add `RenewableLockRegistry.setRenewalTaskScheduler()` and when it is set, schedule a `renew()` script periodically when lock is acquired from Redis with `1/3` of `expireAfter` * Test and document the feature
This commit is contained in:
@@ -856,4 +856,7 @@ Default.
|
||||
The pub-sub is preferred mode - less network chatter between client Redis server, and more performant - the lock is acquired immediately when subscription is notified about unlocking in the other process.
|
||||
However, the Redis does not support pub-sub in the Master/Replica connections (for example in AWS ElastiCache environment), therefore a busy-spin mode is chosen as a default to make the registry working in any environment.
|
||||
|
||||
Starting with version 6.4, instead of throwing `IllegalStateException`, the `RedisLockRegistry.RedisLock.unlock()` method throws `ConcurrentModificationException` if the ownership of the lock is expired.
|
||||
Starting with version 6.4, instead of throwing `IllegalStateException`, the `RedisLockRegistry.RedisLock.unlock()` method throws `ConcurrentModificationException` if the ownership of the lock is expired.
|
||||
|
||||
Starting with version 6.4, a `RedisLockRegistry.setRenewalTaskScheduler()` is added to configure the scheduler for periodic renewal of locks.
|
||||
When it is set, the lock will be automatically renewed every `1/3` of the expiration time after the lock is successfully acquired, until unlocked or the redis key is removed.
|
||||
|
||||
@@ -59,6 +59,7 @@ See xref:zeromq.adoc[ZeroMQ Support] for more information.
|
||||
=== Redis Changes
|
||||
|
||||
Instead of throwing `IllegalStateException`, the `RedisLockRegistry.RedisLock.unlock()` method throws `ConcurrentModificationException` if the ownership of the lock is expired.
|
||||
Add a `RedisLockRegistry.setRenewalTaskScheduler()` to periodic lock renewal.
|
||||
See xref:redis.adoc[Redis Support] for more information.
|
||||
|
||||
[[x6.4-groovy-changes]]
|
||||
|
||||
Reference in New Issue
Block a user