How to invalidate the kazoo lease on zookeeper when the client holding the lease disconnect from zookeeper or crashes

239 Views Asked by At

I am following kazoo lease recipe. Client creates a znode "/db_leases/hourly_cleanup" and acquire the lease. When the client disconnects from the zookeeper or crashes, I want other client, that is trying to acquire the same lease, able to acquire the it. Since znode is not removed, other client fails to acquire the lease even when no other client holding the lease. How to make sure znode "/db_leases/hourly_cleanup" is removed when client holding the lease exits or crashes.

1

There are 1 best solutions below

3
Lars Albertsson On

The other client will not be able to acquire it until the lease expires. Once the time specified by the duration parameter has elapsed, it will be able to acquire the lease.