Skip to content

Commit

Permalink
server: Fix mppcoordinatorMananger server addr empty issue (#52632) (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
ti-chi-bot authored May 9, 2024
1 parent 64ca76e commit 792f20e
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
1 change: 0 additions & 1 deletion cmd/tidb-server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
3 changes: 2 additions & 1 deletion pkg/server/handler/tests/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
11 changes: 11 additions & 0 deletions pkg/server/handler/tests/http_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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:")
}
2 changes: 2 additions & 0 deletions pkg/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 792f20e

Please sign in to comment.