From 8b2e9f978b9a0637bebe90251461d146e6baece5 Mon Sep 17 00:00:00 2001 From: Ti Chi Robot Date: Mon, 6 Nov 2023 16:38:11 +0800 Subject: [PATCH] statistic: improve ipv6 for analyze job meta (#45177) (#45188) ref pingcap/tidb#43260 --- executor/analyze.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/executor/analyze.go b/executor/analyze.go index b0f55eb592561..97ab335b49eb9 100644 --- a/executor/analyze.go +++ b/executor/analyze.go @@ -20,6 +20,7 @@ import ( "fmt" "math" "math/rand" + "net" "sort" "strconv" "strings" @@ -2489,7 +2490,7 @@ func AddNewAnalyzeJob(ctx sessionctx.Context, job *statistics.AnalyzeJob) { logutil.BgLogger().Error("failed to get server info", zap.Error(err)) instance = "unknown" } else { - instance = fmt.Sprintf("%s:%d", serverInfo.IP, serverInfo.Port) + instance = net.JoinHostPort(serverInfo.IP, strconv.Itoa(int(serverInfo.Port))) } statsHandle := domain.GetDomain(ctx).StatsHandle() err = statsHandle.InsertAnalyzeJob(job, instance, ctx.GetSessionVars().ConnectionID)