From 33db8f17fcf63c6df1cdb127143b28f19bcac3a7 Mon Sep 17 00:00:00 2001 From: xiepaup Date: Thu, 12 Dec 2024 16:25:01 +0800 Subject: [PATCH] =?UTF-8?q?fix(redis):=20dbha=E5=88=87=E6=8D=A2=E5=BF=BD?= =?UTF-8?q?=E7=95=A5=E7=8A=B6=E6=80=81=E4=B8=8D=E5=AF=B9=E7=9A=84proxy=20?= =?UTF-8?q?=E5=AF=B9=E6=AF=94=20#8567?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dbha/ha-module/dbmodule/redis/redis_switch.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/dbm-services/common/dbha/ha-module/dbmodule/redis/redis_switch.go b/dbm-services/common/dbha/ha-module/dbmodule/redis/redis_switch.go index 99b56c1e41..acaf72f68d 100644 --- a/dbm-services/common/dbha/ha-module/dbmodule/redis/redis_switch.go +++ b/dbm-services/common/dbha/ha-module/dbmodule/redis/redis_switch.go @@ -423,8 +423,11 @@ func (ins *RedisSwitch) TwemproxySwitchM2S(masterIp string, masterPort int, slav ins.ReportLogs(constvar.InfoResult, fmt.Sprintf("twemproxy switch: from master[%s] -> slave[%s] begin, proxies{%d}.", masterAddr, slaveAddr, len(ins.Proxy))) - + notRunningCnt := 0 for _, proxy := range ins.Proxy { + if proxy.Status != "running" { + notRunningCnt++ + } wg.Add(1) go func(proxyInfo dbutil.ProxyInfo) { defer wg.Done() @@ -459,6 +462,13 @@ func (ins *RedisSwitch) TwemproxySwitchM2S(masterIp string, masterPort int, slav masterAddr, slaveAddr, len(ins.Proxy), successSwitchNum)) return nil } + // ignore status !=running + if int(successSwitchNum)+notRunningCnt >= len(ins.Proxy) { + ins.ReportLogs(constvar.FailResult, + fmt.Sprintf("twemproxy switch: partly proxy switched [tota:%d, succ:%d , norunning:%d]", + len(ins.Proxy), successSwitchNum, notRunningCnt)) + return nil + } ins.ReportLogs(constvar.FailResult, fmt.Sprintf("twemproxy switch: partly proxy switched [tota:%d != succ:%d]", len(ins.Proxy), successSwitchNum))