Skip to content

Commit

Permalink
cherry pick pingcap#20808 to release-4.0
Browse files Browse the repository at this point in the history
Signed-off-by: MyonKeminta <MyonKeminta@users.noreply.github.com>
  • Loading branch information
MyonKeminta committed Nov 5, 2020
1 parent d32969f commit a7eab04
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
4 changes: 4 additions & 0 deletions store/tikv/kv.go
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,10 @@ func (s *tikvStore) Close() error {
s.txnLatches.Close()
}
s.regionCache.Close()

if err := s.kv.Close(); err != nil {
return errors.Trace(err)
}
return nil
}

Expand Down
11 changes: 11 additions & 0 deletions store/tikv/safepoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ type SafePointKV interface {
Put(k string, v string) error
Get(k string) (string, error)
GetWithPrefix(k string) ([]*mvccpb.KeyValue, error)
Close() error
}

// MockSafePointKV implements SafePointKV at mock test
Expand Down Expand Up @@ -90,6 +91,11 @@ func (w *MockSafePointKV) GetWithPrefix(prefix string) ([]*mvccpb.KeyValue, erro
return kvs, nil
}

// Close implements the Close method for SafePointKV
func (w *MockSafePointKV) Close() error {
return nil
}

// EtcdSafePointKV implements SafePointKV at runtime
type EtcdSafePointKV struct {
cli *clientv3.Client
Expand Down Expand Up @@ -140,6 +146,11 @@ func (w *EtcdSafePointKV) GetWithPrefix(k string) ([]*mvccpb.KeyValue, error) {
return resp.Kvs, nil
}

// Close implements the Close for SafePointKV
func (w *EtcdSafePointKV) Close() error {
return errors.Trace(w.cli.Close())
}

func saveSafePoint(kv SafePointKV, t uint64) error {
s := strconv.FormatUint(t, 10)
err := kv.Put(GcSavedSafePoint, s)
Expand Down

0 comments on commit a7eab04

Please sign in to comment.