Open bcwaldon opened 10 years ago
This is a somewhat dangerous bug if people have been using rsync or something to backup their snapshot directory. But, in the common case there is only ever one snapshot file on disk and this is managed by go-raft.
Wow. Something as simple as this should fix it.
https://github.com/otoolep/raft/commit/ffe3da06a7a2a55c809724510392733b3f10a859
@otoolep You actually need to pad both fields, as you need to be able to sort by the last index in the event that the term appears more than once.
...and we need to deal with snapshots that are already out there.
Check the PR -- it pads both fields.
Ah, I didn't realize there was a PR.
I have the following snapshot files:
On startup, the server picks the "latest" snapshot as a starting point. The "latest" snapshot is determined by first sorting all the snapshot files in alphabetical order (as they are above), then choosing the last one [0] . The format of these file names is
<lastTerm>_<lastIndex>.ss
. The intention here is to grab the snapshot from the highest term, falling back to the highest index in case two snapshots were created within the same term. Looking at the sort order above, the last one is clearly not the one with the highest term or highest index.[0] https://github.com/goraft/raft/blob/510993e76b2444b66f2092eba7c30580e7426040/server.go#L1339