etcdserver: remove redundant storage restore operation

This commit is contained in:
tangcong 2020-04-12 00:09:17 +08:00
parent 59f5fb25a5
commit 3c85b67f7b

View File

@ -21,8 +21,6 @@ import (
"go.etcd.io/etcd/etcdserver/api/snap"
"go.etcd.io/etcd/etcdserver/cindex"
"go.etcd.io/etcd/lease"
"go.etcd.io/etcd/mvcc"
"go.etcd.io/etcd/mvcc/backend"
"go.etcd.io/etcd/raft/raftpb"
@ -96,9 +94,7 @@ func openBackend(cfg ServerConfig) backend.Backend {
// case, replace the db with the snapshot db sent by the leader.
func recoverSnapshotBackend(cfg ServerConfig, oldbe backend.Backend, snapshot raftpb.Snapshot) (backend.Backend, error) {
ci := cindex.NewConsistentIndex(oldbe.BatchTx())
kv := mvcc.New(cfg.Logger, oldbe, &lease.FakeLessor{}, ci, mvcc.StoreConfig{CompactionBatchLimit: cfg.CompactionBatchLimit})
defer kv.Close()
if snapshot.Metadata.Index <= kv.ConsistentIndex() {
if snapshot.Metadata.Index <= ci.ConsistentIndex() {
return oldbe, nil
}
oldbe.Close()