raft-rs icon indicating copy to clipboard operation
raft-rs copied to clipboard

Initialize `next_idx` in Raft::new

Open Fullstop000 opened this issue 5 years ago • 2 comments

In Raft::new, we always create a ProgressSet with setting next_idx 1 in each Progress: https://github.com/tikv/raft-rs/blob/f7f7d0121132ef6406b59fc774778285cd1477d6/src/raft.rs#L251-L255

In the situation where recovering the raft node, I think maybe we can just use the current Snapshot's meta index as same as the implementation in restore_raft : https://github.com/tikv/raft-rs/blob/f7f7d0121132ef6406b59fc774778285cd1477d6/src/raft.rs#L1984-L1987

Fullstop000 avatar Dec 11 '19 03:12 Fullstop000

When a peer becomes leader, it will reset next_idx to last_index + 1 for all followers. So I think it's OK?

hicqu avatar Mar 02 '20 09:03 hicqu

I just want to make the implementation stay consistent with resotre_snapmeta :). Feel free to close this.

Fullstop000 avatar Mar 03 '20 03:03 Fullstop000