raft: always write dummy entry to storage

release-2.0
Xiang Li 2014-11-25 23:27:40 -08:00
parent 7614aa53bf
commit 39e6631447
2 changed files with 4 additions and 4 deletions

View File

@ -216,8 +216,8 @@ func (l *raftLog) snap(d []byte, index, term uint64, nodes []uint64) {
}
func (l *raftLog) restore(s pb.Snapshot) {
l.ents = []pb.Entry{{Term: s.Term}}
l.unstable = s.Index + 1
l.ents = []pb.Entry{{Index: s.Index, Term: s.Term}}
l.unstable = s.Index
l.committed = s.Index
l.offset = s.Index
l.snapshot = s

View File

@ -501,8 +501,8 @@ func TestLogRestore(t *testing.T) {
if raftLog.committed != index {
t.Errorf("comitted = %d, want %d", raftLog.committed, index)
}
if raftLog.unstable != index+1 {
t.Errorf("unstable = %d, want %d", raftLog.unstable, index+1)
if raftLog.unstable != index {
t.Errorf("unstable = %d, want %d", raftLog.unstable, index)
}
if raftLog.term(index) != term {
t.Errorf("term = %d, want %d", raftLog.term(index), term)