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,11 +198,19 @@ func WithPDHTTPClient(
opts ...pdhttp.ClientOption, opts ...pdhttp.ClientOption,
) Option { ) Option {
return func(o *KVStore) { return func(o *KVStore) {
o.pdHttpClient = pdhttp.NewClient( if cli := o.GetPDClient(); cli != nil {
source, o.pdHttpClient = pdhttp.NewClientWithServiceDiscovery(
pdAddrs, source,
opts..., o.pdClient.GetServiceDiscovery(),
) opts...,
)
} else {
o.pdHttpClient = pdhttp.NewClient(
source,
pdAddrs,
opts...,
)
}
} }
} }