From 8a8a8253faf7c017a40e3be025b2d35fc7d7c95c Mon Sep 17 00:00:00 2001 From: Xiang Li Date: Sun, 3 Jul 2016 10:16:44 -0700 Subject: [PATCH] etcdserver: commit before sending snapshot --- etcdserver/server.go | 3 +-- etcdserver/snapshot_merge.go | 2 ++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/etcdserver/server.go b/etcdserver/server.go index e8dabb6993f..d535843521d 100644 --- a/etcdserver/server.go +++ b/etcdserver/server.go @@ -1170,8 +1170,7 @@ func (s *EtcdServer) snapshot(snapi uint64, confState raftpb.ConfState) { } plog.Panicf("unexpected create snapshot error %v", err) } - // commit v3 storage because WAL file before snapshot index - // could be removed after SaveSnap. + // commit kv to write metadata (for example: consistent index) to disk. s.KV().Commit() // SaveSnap saves the snapshot and releases the locked wal files // to the snapshot index. diff --git a/etcdserver/snapshot_merge.go b/etcdserver/snapshot_merge.go index eebc6d52279..1de996c507f 100644 --- a/etcdserver/snapshot_merge.go +++ b/etcdserver/snapshot_merge.go @@ -39,6 +39,8 @@ func (s *EtcdServer) createMergedSnapshotMessage(m raftpb.Message, snapi uint64, plog.Panicf("store save should never fail: %v", err) } + // commit kv to write metadata(for example: consistent index). + s.KV().Commit() dbsnap := s.be.Snapshot() // get a snapshot of v3 KV as readCloser rc := newSnapshotReaderCloser(dbsnap)