From 383d3341b1764ae9eb50b8d268a88c32cc6518da Mon Sep 17 00:00:00 2001 From: "zhuzhao.cx" Date: Mon, 4 Mar 2019 21:21:53 +0800 Subject: [PATCH] polish --- src/redis-shake/sync.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/redis-shake/sync.go b/src/redis-shake/sync.go index b164894..636b8ef 100644 --- a/src/redis-shake/sync.go +++ b/src/redis-shake/sync.go @@ -419,10 +419,15 @@ func (cmd *CmdSync) SyncCommand(reader *bufio.Reader, target, auth_type, passwd } } - if node != nil && node.id == recvId.Get() { - // cmd.SyncStat.Delay.Add(time.Now().Sub(node.t).Nanoseconds()) - metric.MetricVar.AddDelay(uint64(time.Now().Sub(node.t).Nanoseconds()) / 1000000) // ms - node = nil + if node != nil { + id := recvId.Get() // receive id + if node.id == id { + // cmd.SyncStat.Delay.Add(time.Now().Sub(node.t).Nanoseconds()) + metric.MetricVar.AddDelay(uint64(time.Now().Sub(node.t).Nanoseconds()) / 1000000) // ms + node = nil + } else if node.id > id { + log.Panicf("receive id invalid: node-id[%v] > receive-id[%v]", node.id, id) + } } } }()