diff --git a/server/cluster/cluster.go b/server/cluster/cluster.go index 7cbb2cbdab2..56c5e07be98 100644 --- a/server/cluster/cluster.go +++ b/server/cluster/cluster.go @@ -311,7 +311,7 @@ func syncConfig(ctx context.Context, manager *config.StoreConfigManager, stores for index := 0; index < len(stores); index++ { select { case <-ctx.Done(): - log.Info("stop sync store config job due to server shutdown") + log.Info("stop sync store config job due to raft cluster exited") return false default: } diff --git a/server/config/store_config.go b/server/config/store_config.go index 81a13a7e734..bd7d7465776 100644 --- a/server/config/store_config.go +++ b/server/config/store_config.go @@ -15,7 +15,6 @@ package config import ( - "bytes" "context" "encoding/json" "fmt" @@ -231,19 +230,17 @@ func newTiKVConfigSource(schema string, client *http.Client) *TiKVConfigSource { func (s TiKVConfigSource) GetConfig(ctx context.Context, statusAddress string) (*StoreConfig, error) { url := fmt.Sprintf("%s://%s/config", s.schema, statusAddress) ctx, cancel := context.WithTimeout(ctx, clientTimeout) - req, err := http.NewRequestWithContext(ctx, http.MethodGet, url, bytes.NewBuffer(nil)) + req, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil) + defer cancel() if err != nil { - cancel() return nil, fmt.Errorf("failed to create store config http request: %w", err) } resp, err := s.client.Do(req) if err != nil { - cancel() return nil, err } defer resp.Body.Close() body, err := io.ReadAll(resp.Body) - cancel() if err != nil { return nil, err }