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)