diff --git a/cmd/tidb-server/main.go b/cmd/tidb-server/main.go index 0fffc9e7c407a..e2fec3206ce12 100644 --- a/cmd/tidb-server/main.go +++ b/cmd/tidb-server/main.go @@ -901,7 +901,6 @@ func createServer(storage kv.Storage, dom *domain.Domain) *server.Server { closeDomainAndStorage(storage, dom) log.Fatal("failed to create the server", zap.Error(err), zap.Stack("stack")) } - mppcoordmanager.InstanceMPPCoordinatorManager.InitServerAddr(svr.GetStatusServerAddr()) svr.SetDomain(dom) go dom.ExpensiveQueryHandle().SetSessionManager(svr).Run() go dom.MemoryUsageAlarmHandle().SetSessionManager(svr).Run() diff --git a/pkg/server/handler/tests/BUILD.bazel b/pkg/server/handler/tests/BUILD.bazel index 415990a07d3a3..687e94eef2ff8 100644 --- a/pkg/server/handler/tests/BUILD.bazel +++ b/pkg/server/handler/tests/BUILD.bazel @@ -9,13 +9,14 @@ go_test( "main_test.go", ], flaky = True, - shard_count = 38, + shard_count = 39, deps = [ "//pkg/config", "//pkg/ddl", "//pkg/ddl/util", "//pkg/domain", "//pkg/domain/infosync", + "//pkg/executor/mppcoordmanager", "//pkg/infoschema", "//pkg/kv", "//pkg/meta", diff --git a/pkg/server/handler/tests/http_handler_test.go b/pkg/server/handler/tests/http_handler_test.go index b2726b7f5a848..ea40ec0968246 100644 --- a/pkg/server/handler/tests/http_handler_test.go +++ b/pkg/server/handler/tests/http_handler_test.go @@ -40,6 +40,7 @@ import ( "github.com/pingcap/tidb/pkg/ddl" "github.com/pingcap/tidb/pkg/domain" "github.com/pingcap/tidb/pkg/domain/infosync" + "github.com/pingcap/tidb/pkg/executor/mppcoordmanager" "github.com/pingcap/tidb/pkg/infoschema" "github.com/pingcap/tidb/pkg/kv" "github.com/pingcap/tidb/pkg/meta" @@ -1502,3 +1503,13 @@ func testUpgradeShow(t *testing.T, ts *basicHTTPHandlerTestSuite) { require.NoError(t, failpoint.Enable("github.com/pingcap/tidb/pkg/domain/infosync/mockGetAllServerInfo", makeFailpointRes(mockedAllServerInfos))) checkUpgradeShow(3, 100, 0) } + +func TestIssue52608(t *testing.T) { + ts := createBasicHTTPHandlerTestSuite() + + ts.startServer(t) + defer ts.stopServer(t) + on, addr := mppcoordmanager.InstanceMPPCoordinatorManager.GetServerAddr() + require.Equal(t, on, true) + require.Equal(t, addr[:10], "127.0.0.1:") +} diff --git a/pkg/server/server.go b/pkg/server/server.go index 394573bb58b4f..448dd39750f67 100644 --- a/pkg/server/server.go +++ b/pkg/server/server.go @@ -53,6 +53,7 @@ import ( autoid "github.com/pingcap/tidb/pkg/autoid_service" "github.com/pingcap/tidb/pkg/config" "github.com/pingcap/tidb/pkg/domain" + "github.com/pingcap/tidb/pkg/executor/mppcoordmanager" "github.com/pingcap/tidb/pkg/extension" "github.com/pingcap/tidb/pkg/kv" "github.com/pingcap/tidb/pkg/metrics" @@ -436,6 +437,7 @@ func (s *Server) Run(dom *domain.Domain) error { log.Error("failed to create the server", zap.Error(err), zap.Stack("stack")) return err } + mppcoordmanager.InstanceMPPCoordinatorManager.InitServerAddr(s.GetStatusServerAddr()) } if config.GetGlobalConfig().Performance.ForceInitStats && dom != nil { <-dom.StatsHandle().InitStatsDone