Skip to content

Commit 39146a0

Browse files
committed
fix: allocate 2 consecutive free ports for ProxySQL (admin + mysql) to avoid TIME_WAIT conflicts
1 parent fdaccfd commit 39146a0

2 files changed

Lines changed: 11 additions & 5 deletions

File tree

cmd/deploy_proxysql.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ func deploySandboxProxySQL(cmd *cobra.Command, args []string) {
4141
common.Exitf(1, "proxysql binary not found in PATH: %s", err)
4242
}
4343

44+
// Find 2 consecutive free ports (admin + mysql)
45+
freePort, portErr := common.FindFreePort(port, []int{}, 2)
46+
if portErr == nil {
47+
port = freePort
48+
}
49+
4450
sandboxHome := defaults.Defaults().SandboxHome
4551
sandboxDir := path.Join(sandboxHome, fmt.Sprintf("proxysql_%d", port))
4652

sandbox/proxysql_topology.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ func DeployProxySQLForTopology(sandboxDir string, masterPort int, slavePorts []i
3232

3333
if proxysqlPort == 0 {
3434
proxysqlPort = 6032
35-
// Try to find a free port
36-
freePort, err := common.FindFreePort(proxysqlPort, []int{}, 1)
37-
if err == nil {
38-
proxysqlPort = freePort
39-
}
35+
}
36+
// Find 2 consecutive free ports (admin + mysql) to avoid TIME_WAIT conflicts
37+
freePort, err := common.FindFreePort(proxysqlPort, []int{}, 2)
38+
if err == nil {
39+
proxysqlPort = freePort
4040
}
4141

4242
// Build backends: master = HG 0, slaves = HG 1

0 commit comments

Comments
 (0)