diff --git a/src/backend/booster/server/pkg/rd/rd.go b/src/backend/booster/server/pkg/rd/rd.go index da243601..6538b740 100644 --- a/src/backend/booster/server/pkg/rd/rd.go +++ b/src/backend/booster/server/pkg/rd/rd.go @@ -340,26 +340,28 @@ func (erd *etcdRegisterDiscover) watch() { for { select { case resp := <-watchChan: - blog.Infof("rd: watch resp [%+v]", resp) - for _, ev := range resp.Events { - blog.Infof("rd: watch event [%s %q : %q]", ev.Type, ev.Kv.Key, ev.Kv.Value) - if ev.Type == etcdClient.EventTypePut { - if string(ev.Kv.Value) == string(erd.serverInfo) { - blog.Infof("rd: watch resp [found self succeed put]") - erd.selfServerKey = string(ev.Kv.Key) - blog.Infof("rd: watch resp erd.selfServerKey is[%s]", erd.selfServerKey) - } - } else if ev.Type == etcdClient.EventTypeDelete { - if string(ev.Kv.Key) == erd.selfServerKey { - blog.Infof("rd: watch resp [found self succeed delete]") - erd.selfServerKey = "" - // 通知manager重置 - erd.reset() + if len(resp.Events) > 0 { + blog.Infof("rd: watch resp [%+v]", resp) + for _, ev := range resp.Events { + blog.Infof("rd: watch event [%s %q : %q]", ev.Type, ev.Kv.Key, ev.Kv.Value) + if ev.Type == etcdClient.EventTypePut { + if string(ev.Kv.Value) == string(erd.serverInfo) { + blog.Infof("rd: watch resp [found self succeed put]") + erd.selfServerKey = string(ev.Kv.Key) + blog.Infof("rd: watch resp erd.selfServerKey is[%s]", erd.selfServerKey) + } + } else if ev.Type == etcdClient.EventTypeDelete { + if string(ev.Kv.Key) == erd.selfServerKey { + blog.Infof("rd: watch resp [found self succeed delete]") + erd.selfServerKey = "" + // 通知manager重置 + erd.reset() + } } } - } - erd.updateServerInfo() + erd.updateServerInfo() + } } } }