lni / dragonboat

A feature complete and high performance multi-group Raft library in Go.
Apache License 2.0
5.06k stars 541 forks source link

[Help wanted]How to determine if a new-joined node is caught up with current lead node and ready for serve? #324

Closed BetaCat0 closed 1 year ago

BetaCat0 commented 1 year ago

Dragonboat version

v4

Hi Lni, I'm trying to migrate from etcd to dragnoboat for mulit-raft support. In ectd I could use status.Progress in leaderNode.Status() for a progress check before promoting a new-joined node to a voter. I'm unsure if dragnoboat support so or if there is another way to perform a progress check. Could you give me some suggestions?

lni commented 1 year ago

In dragonboat, you should add a newly joined node as non-voting node first, it will start to get updates/logs from the leader. You can then periodically, say once per second, check whether the non-voting node is ready to do linearizable read (see docs of the ReadIndex method and the description of the read index protocol in the raft thesis). Once such a linearizable read can be successfully completed, it means the non-voting node has all up to date logs when that linearizable read was performed. It gives you very high confidence that at that time the node should be no more than a couple seconds late than the leader in terms of log replication. You can then promote it to a full member node.

Note that the overhead of such periodic ReadIndex is minimum - in my tests, a server can easily handle millions of such requests per second and you are just using 1 out of that millions per second.

BetaCat0 commented 1 year ago

Thanks :)