Skip to content

Commit

Permalink
Merge pull request #1792 from xiang90/fix_raft_l
Browse files Browse the repository at this point in the history
raft: always write dummy entry to storage
  • Loading branch information
xiang90 committed Nov 26, 2014
2 parents 7614aa5 + 39e6631 commit d01d611
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions raft/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions raft/log_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit d01d611

Please sign in to comment.