From da1e947ecead2d1ed546000d0e797c04a9a59f8f Mon Sep 17 00:00:00 2001 From: Ti Chi Robot Date: Thu, 27 Jul 2023 16:46:36 +0800 Subject: [PATCH] *: Fix data race in TestSetLabelsConcurrentWithGetLabel (#45579) (#45588) close pingcap/tidb#45578 --- server/http_handler_test.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/server/http_handler_test.go b/server/http_handler_test.go index ecf578f4a0f6b..926a5d99b6997 100644 --- a/server/http_handler_test.go +++ b/server/http_handler_test.go @@ -1196,7 +1196,9 @@ func TestSetLabels(t *testing.T) { testUpdateLabels(updated, labels) // reset the global variable - config.GetGlobalConfig().Labels = map[string]string{} + config.UpdateGlobal(func(conf *config.Config) { + conf.Labels = map[string]string{} + }) } func TestSetLabelsConcurrentWithGetLabel(t *testing.T) { @@ -1237,5 +1239,7 @@ func TestSetLabelsConcurrentWithGetLabel(t *testing.T) { close(done) // reset the global variable - config.GetGlobalConfig().Labels = map[string]string{} + config.UpdateGlobal(func(conf *config.Config) { + conf.Labels = map[string]string{} + }) }