diff --git a/executor/analyze.go b/executor/analyze.go index 8f87ac944ac4f..16ccce8074156 100644 --- a/executor/analyze.go +++ b/executor/analyze.go @@ -18,6 +18,7 @@ import ( "context" "fmt" "math" + "net" "strconv" "strings" "sync/atomic" @@ -466,7 +467,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)