|
|
@@ -389,6 +389,7 @@ func (s *EtcdServer) run() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ // apply snapshot to storage if it is more updated than current snapi
|
|
|
if !raft.IsEmptySnap(rd.Snapshot) && rd.Snapshot.Metadata.Index > snapi {
|
|
|
if err := s.storage.SaveSnap(rd.Snapshot); err != nil {
|
|
|
log.Fatalf("etcdserver: create snapshot error: %v", err)
|
|
|
@@ -396,15 +397,17 @@ func (s *EtcdServer) run() {
|
|
|
s.raftStorage.ApplySnapshot(rd.Snapshot)
|
|
|
snapi = rd.Snapshot.Metadata.Index
|
|
|
}
|
|
|
+
|
|
|
if err := s.storage.Save(rd.HardState, rd.Entries); err != nil {
|
|
|
log.Fatalf("etcdserver: save state and entries error: %v", err)
|
|
|
}
|
|
|
s.raftStorage.Append(rd.Entries)
|
|
|
+
|
|
|
s.sendhub.Send(rd.Messages)
|
|
|
|
|
|
- if !raft.IsEmptySnap(rd.Snapshot) {
|
|
|
- // recover from snapshot if it is more updated than current applied
|
|
|
- if rd.Snapshot.Metadata.Index > appliedi {
|
|
|
+ // recover from snapshot if it is more updated than current applied
|
|
|
+ if !raft.IsEmptySnap(rd.Snapshot) && rd.Snapshot.Metadata.Index > appliedi {
|
|
|
+ {
|
|
|
if err := s.store.Recovery(rd.Snapshot.Data); err != nil {
|
|
|
log.Panicf("recovery store error: %v", err)
|
|
|
}
|