File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ import (
21
21
"fmt"
22
22
"net"
23
23
"net/http"
24
+ "runtime"
24
25
"slices"
25
26
"sort"
26
27
"strconv"
@@ -1981,8 +1982,22 @@ func GetClusterServerInfo(ctx sessionctx.Context) ([]ServerInfo, error) {
1981
1982
if err != nil {
1982
1983
return nil , err
1983
1984
}
1985
+
1986
+ // Create an error group with Panic recovery and concurrency limit
1987
+ resolveGroup := util .NewErrorGroupWithRecover ()
1988
+ resolveGroup .SetLimit (runtime .GOMAXPROCS (0 )) //Limit concurrency to number of CPU cores
1989
+
1990
+ // Resolve loopback addresses concurrently for each node
1984
1991
for i := range nodes {
1985
- nodes [i ].ResolveLoopBackAddr ()
1992
+ resolveGroup .Go (func () error {
1993
+ nodes [i ].ResolveLoopBackAddr ()
1994
+ return nil
1995
+ })
1996
+ }
1997
+
1998
+ // Wait for all address resolutions to complete and check for errors
1999
+ if err := resolveGroup .Wait (); err != nil {
2000
+ return nil , err
1986
2001
}
1987
2002
servers = append (servers , nodes ... )
1988
2003
}
You can’t perform that action at this time.
0 commit comments