How does the etcd client perform leader election under the hood? #14738
Unanswered
shreemaan-abhishek
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
When
concurrency.NewSession()
is called, a new lease in the db is created.Whereas the
election.Campaign()
a new key-value pair is created in the db. As many key-value pairs are created as the number of participants in the leader election. I am unable to figure out how these pieces fit into the picture together to perform leader election. My best guess is that the participants update the session lease in some way but I cannot see them. Even when using theetcdctl lease list -w json
command.While studying the code I found something, here:
Line number 75 shows that the session lease is also a part of the transaction. Is it that only one instance is allowed to hold the lease? If yes, how?
Also, there is no way to get all the keys/prefixes in the etcd database. So I cannot check if anything else is happening in the database.
Beta Was this translation helpful? Give feedback.
All reactions