Modify request_snapshot API, remove parameter: request_index: u64, use last_index as request_index, when sending request snapshot.
Reason
When a follower uses this interface to actively request a snapshot from the leader, it is not safe to pass an arbitrary index, as the leader will continue to send AppendRPC before receiving the snapshot request, this gap log follower is difficult to handle. Eg: it may panic at https://github.com/tikv/raft-rs/blob/5ce52b480065ff31ecef16b9b77c7c3b7c57c8c7/src/raw_node.rs#L520-L529. So the safest way is to use last_index as request_index, and the follower rejects appendRPC.
Change
Modify
request_snapshot
API, remove parameter:request_index: u64
, uselast_index
asrequest_index
, when sending request snapshot.Reason
When a follower uses this interface to actively request a snapshot from the leader, it is not safe to pass an arbitrary index, as the leader will continue to send AppendRPC before receiving the snapshot request, this gap log follower is difficult to handle. Eg: it may panic at https://github.com/tikv/raft-rs/blob/5ce52b480065ff31ecef16b9b77c7c3b7c57c8c7/src/raw_node.rs#L520-L529. So the safest way is to use
last_index
asrequest_index
, and the follower rejectsappendRPC
.close tikv/raft-rs#498
Signed-off-by: Wenbo Zhang ethercflow@gmail.com