Hoverbear / old-raft-rs

[Incomplete] A Raft implementation in Rust
https://hoverbear.github.io/raft-rs/raft/
MIT License
266 stars 41 forks source link

Clear connection send queues on state change #55

Closed danburkert closed 9 years ago

danburkert commented 9 years ago

All messages to be delivered to remote peers from the local Replica are added to a send queue, and asynchronously processed as individual TCP streams become writable. When the local Replica's state changes, these queues should be cleared. Note that if a message is partially sent, then it should still be sent, since the receiving peer has no way to handle partially sent messages.

Justification for clearing the queue for each possible state change:

Old State New State Action
Follower Candidate no messages should be queued to begin with
Candidate Leader only RequestVoteRequests should be queued, and they are no longer necessary
Candidate Follower only RequestVoteRequests are queued, and they are no longer valid
Leader Follower only AppendEntryReqeuests should be queued, and they are no longer valid
Hoverbear commented 9 years ago

We should also clear on inconsistentPrevEntry as we know that all future commands sent will fail as well and we need to roll them back and catch them up.