lni / dragonboat

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

Seems witnesses shouldn't be count when committing entries #106

Closed hicqu closed 5 years ago

hicqu commented 5 years ago

Note: for reported bugs, please fill in the following details. bug reports without detailed steps on how to reproduce will be automatically closed.

Dragonboat version

master.

Expected behavior

I guess it's better if witnesses won't be count when committing entries.

Suppose we have a Raft group with nodes A, B, C, D E. A, B are in one datacenter and C, D are in an another one. All of them are voters except E, which is a witness. For now if any datacenter fails, we could lost some latest writes if those entries are committed by A, B, E or C, D, E. This problem can be resolved if we don't count witness when trying to commit entries.

Actual behavior

Seems in function tryCommit, witnesses are counted when committing entries.

Steps to reproduce the behavior

Not need. Just read the code is enough.

lni commented 5 years ago

For now if any datacenter fails, we could lost some latest writes if those entries are committed by A, B, E or C, D, E.

This is expected. A witness node doesn't have the actual log, there is a price to pay for that and that price is the reduced availability.

Such reduced availability impact has also been analyzed in details in the context of Raft by the author who first came up with the witness idea. Please see the paper below.

https://www.researchgate.net/publication/280091830_Reducing_the_Energy_Footprint_of_a_Distributed_Consensus_Algorithm