willemt / raft

C implementation of the Raft Consensus protocol, BSD licensed
Other
1.13k stars 271 forks source link

only remove nodes from node list after removal is commited to removed node #117

Closed sjpotter closed 3 years ago

sjpotter commented 3 years ago

currently, the leader removes the node from its list of nodes as soon as it commits its own log entry.

what this means, is that the removed node will never commit the log entry of removal. this seems wrong to me.

I've modified the code to mark the node removed on commit to leader, but only actually remove the node after appendentries_all (i.e. with updated commit idx) is sent succesfully to the node

It's possible, that this is problematic. i.e. what happens if node is dead (so can't send message). open to better logic for determining when to remvoe node

sjpotter commented 3 years ago

other thoughts, this code as is (probably) buggy, as modifies node list while iterating. PR is mostly as a POC to point out what I'm trying to accomplish. make sure (as much as possible) that remove log entry is commited to removed node.