Skip to content

Commit

Permalink
clientv3/snapshot: cleanup initIndex
Browse files Browse the repository at this point in the history
  • Loading branch information
tangcong committed Mar 18, 2020
1 parent d0e273e commit a5d5ad3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
8 changes: 0 additions & 8 deletions clientv3/snapshot/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ package snapshot

import (
"encoding/binary"
"go.etcd.io/etcd/mvcc/backend"
)

type revision struct {
Expand All @@ -30,10 +29,3 @@ func bytesToRev(bytes []byte) revision {
sub: int64(binary.BigEndian.Uint64(bytes[9:])),
}
}

// initIndex implements ConsistentIndexGetter so the snapshot won't block
// the new raft instance by waiting for a future raft index.
type initIndex int

func (i *initIndex) ConsistentIndex() uint64 { return uint64(*i) }
func (i *initIndex) Save(backend.BatchTx) {}
5 changes: 4 additions & 1 deletion clientv3/snapshot/v3_snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import (
"go.etcd.io/etcd/etcdserver/api/membership"
"go.etcd.io/etcd/etcdserver/api/snap"
"go.etcd.io/etcd/etcdserver/api/v2store"
"go.etcd.io/etcd/etcdserver/cindex"
"go.etcd.io/etcd/etcdserver/etcdserverpb"
"go.etcd.io/etcd/lease"
"go.etcd.io/etcd/mvcc"
Expand Down Expand Up @@ -384,7 +385,9 @@ func (s *v3Manager) saveDB() error {
// a lessor never timeouts leases
lessor := lease.NewLessor(s.lg, be, lease.LessorConfig{MinLeaseTTL: math.MaxInt64})

mvs := mvcc.NewStore(s.lg, be, lessor, (*initIndex)(&commit), mvcc.StoreConfig{CompactionBatchLimit: math.MaxInt32})
ci := cindex.NewConsistentIndex()
ci.SetConsistentIndex(uint64(commit))
mvs := mvcc.NewStore(s.lg, be, lessor, &ci, mvcc.StoreConfig{CompactionBatchLimit: math.MaxInt32})
txn := mvs.Write(traceutil.TODO())
btx := be.BatchTx()
del := func(k, v []byte) error {
Expand Down

0 comments on commit a5d5ad3

Please sign in to comment.