diff --git a/integration_tests/pd_api_test.go b/integration_tests/pd_api_test.go index 1a19ba52..2da4c4bf 100644 --- a/integration_tests/pd_api_test.go +++ b/integration_tests/pd_api_test.go @@ -205,7 +205,7 @@ func (s *apiTestSuite) TestInitClusterMinResolvedTSZero() { func (s *apiTestSuite) TearDownTest() { if s.store != nil { - s.Require().Nil(s.store.Close()) + s.Require().NoError(s.store.Close()) } s.Require().NoError(failpoint.Disable("tikvclient/mockFastSafeTSUpdater")) } diff --git a/tikv/kv.go b/tikv/kv.go index 2d21ab9e..47006f9e 100644 --- a/tikv/kv.go +++ b/tikv/kv.go @@ -198,11 +198,19 @@ func WithPDHTTPClient( opts ...pdhttp.ClientOption, ) Option { return func(o *KVStore) { - o.pdHttpClient = pdhttp.NewClient( - source, - pdAddrs, - opts..., - ) + if cli := o.GetPDClient(); cli != nil { + o.pdHttpClient = pdhttp.NewClientWithServiceDiscovery( + source, + o.pdClient.GetServiceDiscovery(), + opts..., + ) + } else { + o.pdHttpClient = pdhttp.NewClient( + source, + pdAddrs, + opts..., + ) + } } }