This ensures that v3 storage could always find the following log entries when restart.
@@ -1029,6 +1029,13 @@ func (s *EtcdServer) snapshot(snapi uint64, confState raftpb.ConfState) {
}
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 {
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) Hash() (uint32, error) { return 0, nil }
func (kv *nopKV) Snapshot() dstorage.Snapshot { return &fakeSnapshot{} }
+func (kv *nopKV) Commit() {}
func (kv *nopKV) Restore() error { return nil }
func (kv *nopKV) Close() error { return nil }
@@ -69,6 +69,9 @@ type KV interface {
// Snapshot snapshots the full KV store.
Snapshot() Snapshot
+ // Commit commits txns into the underlying backend.
+ Commit()
+
Restore() error
Close() error
@@ -294,6 +294,8 @@ func (s *store) Snapshot() Snapshot {
return s.b.Snapshot()
+func (s *store) Commit() { s.b.ForceCommit() }
func (s *store) Restore() error {
s.mu.Lock()
defer s.mu.Unlock()