Skip to content

Commit

Permalink
fix(redis): dbha切换忽略状态不对的proxy 对比 #8567
Browse files Browse the repository at this point in the history
  • Loading branch information
xiepaup authored and iSecloud committed Dec 12, 2024
1 parent 4771f6f commit 33db8f1
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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))
Expand Down

0 comments on commit 33db8f1

Please sign in to comment.