How to configure the heartbeat duration/deadline/time for leader election performed using client/v3? #14655
-
I was using this sample program to understand how leader election happens under the hood in etcd when using the etcd client. I build and run the program in two separate shell instances. One of the instances becomes the leader and executes whereas the other one blocks. When I interrupt the leader instance using ^C, the program execution ends but the lease is still held by the dead program. Ideally, the lease object should vanish as soon as the active process ends. By default, the time taken by the lease object to vanish away is too long. How do I make it shorter? Here's a video of the demo: https://www.youtube.com/watch?v=qqr1MXOLizI |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
The session has TTL and lease arguments for such crash scenarios: |
Beta Was this translation helpful? Give feedback.
The session has TTL and lease arguments for such crash scenarios:
https://github.com/etcd-io/etcd/blob/main/client/v3/concurrency/session.go#L113-L141