fix goroutine leak

Signed-off-by: lance6716 <lance6716@gmail.com>
This commit is contained in:
lance6716 2024-01-23 16:05:55 +08:00
parent 29355d50d1
commit cfee5d73dd
2 changed files with 14 additions and 6 deletions

View File

@ -205,7 +205,7 @@ func (s *apiTestSuite) TestInitClusterMinResolvedTSZero() {
func (s *apiTestSuite) TearDownTest() { func (s *apiTestSuite) TearDownTest() {
if s.store != nil { if s.store != nil {
s.Require().Nil(s.store.Close()) s.Require().NoError(s.store.Close())
} }
s.Require().NoError(failpoint.Disable("tikvclient/mockFastSafeTSUpdater")) s.Require().NoError(failpoint.Disable("tikvclient/mockFastSafeTSUpdater"))
} }

View File

@ -198,12 +198,20 @@ func WithPDHTTPClient(
opts ...pdhttp.ClientOption, opts ...pdhttp.ClientOption,
) Option { ) Option {
return func(o *KVStore) { return func(o *KVStore) {
if cli := o.GetPDClient(); cli != nil {
o.pdHttpClient = pdhttp.NewClientWithServiceDiscovery(
source,
o.pdClient.GetServiceDiscovery(),
opts...,
)
} else {
o.pdHttpClient = pdhttp.NewClient( o.pdHttpClient = pdhttp.NewClient(
source, source,
pdAddrs, pdAddrs,
opts..., opts...,
) )
} }
}
} }
// loadOption load KVStore option into KVStore. // loadOption load KVStore option into KVStore.