mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
etcdserver: cleanup main loop
This commit is contained in:
parent
7e6e305c4f
commit
74d8c7f457
@ -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)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user