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
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.
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 localReplica
'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:
RequestVoteRequest
s should be queued, and they are no longer necessaryRequestVoteRequest
s are queued, and they are no longer validAppendEntryReqeuest
s should be queued, and they are no longer valid