cojen / TuplDB

TuplDB is a high-performance, concurrent, transactional, scalable, low-level embedded database.
GNU Affero General Public License v3.0
110 stars 22 forks source link

Allow leader to pull data from other members #113

Closed broneill closed 5 years ago

broneill commented 5 years ago

When all group members have the "normal" role, replication follows the Raft algorithm. Group members which have any other kind of role cannot become the leader, which can cause issues. It permits a replica to have data which a new leader might have rolled back. The replica at this point rejects all new updates from the leader, because they conflict.

A simple way to resolve the issue is to restart the replica, and then it restores from a checkpoint, which was durable. Unfortunately, this means the replica accepted updates which were then rolled back.

Another solution is to allow the new leader to pull data from all available members, essentially extending the log prior to the new term. This does violate the Raft algorithm, and so it might cause issues.

A safer solution could permit a non-privileged member to become a leader, but it won't accept any updates. When at least one normal member has caught up, then a new election is held.