eBay / NuRaft

C++ implementation of Raft core logic as a replication library
Apache License 2.0
1k stars 237 forks source link

Merge two clusters into one #510

Open anthonio9 opened 4 months ago

anthonio9 commented 4 months ago

Hi,

RAFT seems to be what I need for a consensus leader election algorithm and your implementation fits my needs very well. I went through the examples, tried the echo_server one and have come up with some questions. In a zero conf setup, what would be the best way of learning about other nodes?

This issue could be easily solved if RAFT clusters could merge. If two clusters are present, one with 3 nodes, the other with 5 nodes, is it possible for the leader of the latter cluster to add the first cluster leader with all of its followers to the latter cluster and therefore merging the two clusters into one cluster of 8 nodes?

I could not find anything about such scenario in your documentation except for the part which says that NuRaft implements Dynamic membership & configuration change - that may not be enough.

greensky00 commented 4 months ago

Hi @anthonio9

Merging two separate clusters is not doable. Such functionality is undefined due to possible state machine data conflict. Imagine cluster1 has key="a", value="x" and cluster2 has key="a", value="y", and how to resolve it is out of scope of Raft.

If what you want is simply letting members in cluster2 join cluster1 (and giving up the data that cluster2 has), 1) wiping out all data in state machine and log store and then 2) calling add_srv for each member one by one will work.