Browse Source

raft: memory storage does not append out of date entries

Xiang Li 11 years ago
parent
commit
9bd1786fe4
1 changed files with 4 additions and 0 deletions
  1. 4 0
      raft/storage.go

+ 4 - 0
raft/storage.go

@@ -182,6 +182,10 @@ func (ms *MemoryStorage) Append(entries []pb.Entry) {
 		return
 	}
 	offset := entries[0].Index - ms.snapshot.Metadata.Index
+	// do not append out of date entries
+	if offset < 0 {
+		return
+	}
 	if uint64(len(ms.ents)) >= offset {
 		ms.ents = ms.ents[:offset]
 	}