Browse Source

etcdserver: do not applySnapshot twice

Xiang Li 11 years ago
parent
commit
01cbcce8ba
2 changed files with 2 additions and 1 deletions
  1. 0 1
      etcdserver/server.go
  2. 2 0
      raft/log.go

+ 0 - 1
etcdserver/server.go

@@ -394,7 +394,6 @@ func (s *EtcdServer) run() {
 				if err := s.storage.SaveSnap(rd.Snapshot); err != nil {
 					log.Fatalf("etcdserver: create snapshot error: %v", err)
 				}
-				s.raftStorage.ApplySnapshot(rd.Snapshot)
 				snapi = rd.Snapshot.Metadata.Index
 			}
 

+ 2 - 0
raft/log.go

@@ -245,6 +245,8 @@ func (l *raftLog) maybeCommit(maxIndex, term uint64) bool {
 }
 
 func (l *raftLog) restore(s pb.Snapshot) {
+	// TODO: rethink restore logic.
+	// This breaks the rule that raft never modifies storage.
 	err := l.storage.ApplySnapshot(s)
 	if err != nil {
 		panic(err) // TODO(bdarnell)