mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
etcdserver: commit v3 storage before releasing WAL
This ensures that v3 storage could always find the following log entries when restart.
This commit is contained in:
parent
7e38f05ceb
commit
263b270708
@ -1029,6 +1029,13 @@ func (s *EtcdServer) snapshot(snapi uint64, confState raftpb.ConfState) {
|
|||||||
}
|
}
|
||||||
plog.Panicf("unexpected create snapshot error %v", err)
|
plog.Panicf("unexpected create snapshot error %v", err)
|
||||||
}
|
}
|
||||||
|
if s.cfg.V3demo {
|
||||||
|
// commit v3 storage because WAL file before snapshot index
|
||||||
|
// could be removed after SaveSnap.
|
||||||
|
s.kv.Commit()
|
||||||
|
}
|
||||||
|
// SaveSnap saves the snapshot and releases the locked wal files
|
||||||
|
// to the snapshot index.
|
||||||
if err := s.r.storage.SaveSnap(snap); err != nil {
|
if err := s.r.storage.SaveSnap(snap); err != nil {
|
||||||
plog.Fatalf("save snapshot error: %v", err)
|
plog.Fatalf("save snapshot error: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -186,6 +186,7 @@ func (kv *nopKV) TxnDeleteRange(txnID int64, key, end []byte) (n, rev int64, err
|
|||||||
func (kv *nopKV) Compact(rev int64) error { return nil }
|
func (kv *nopKV) Compact(rev int64) error { return nil }
|
||||||
func (kv *nopKV) Hash() (uint32, error) { return 0, nil }
|
func (kv *nopKV) Hash() (uint32, error) { return 0, nil }
|
||||||
func (kv *nopKV) Snapshot() dstorage.Snapshot { return &fakeSnapshot{} }
|
func (kv *nopKV) Snapshot() dstorage.Snapshot { return &fakeSnapshot{} }
|
||||||
|
func (kv *nopKV) Commit() {}
|
||||||
func (kv *nopKV) Restore() error { return nil }
|
func (kv *nopKV) Restore() error { return nil }
|
||||||
func (kv *nopKV) Close() error { return nil }
|
func (kv *nopKV) Close() error { return nil }
|
||||||
|
|
||||||
|
@ -69,6 +69,9 @@ type KV interface {
|
|||||||
// Snapshot snapshots the full KV store.
|
// Snapshot snapshots the full KV store.
|
||||||
Snapshot() Snapshot
|
Snapshot() Snapshot
|
||||||
|
|
||||||
|
// Commit commits txns into the underlying backend.
|
||||||
|
Commit()
|
||||||
|
|
||||||
Restore() error
|
Restore() error
|
||||||
Close() error
|
Close() error
|
||||||
}
|
}
|
||||||
|
@ -294,6 +294,8 @@ func (s *store) Snapshot() Snapshot {
|
|||||||
return s.b.Snapshot()
|
return s.b.Snapshot()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *store) Commit() { s.b.ForceCommit() }
|
||||||
|
|
||||||
func (s *store) Restore() error {
|
func (s *store) Restore() error {
|
||||||
s.mu.Lock()
|
s.mu.Lock()
|
||||||
defer s.mu.Unlock()
|
defer s.mu.Unlock()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user