From 224a0a28e04ac75ff89ad9d758e04089f30188d4 Mon Sep 17 00:00:00 2001 From: Steven Wolfe Date: Wed, 13 Feb 2019 15:46:18 -0700 Subject: [PATCH] Avoid failing if replconf isn't supported --- internal/server/follow.go | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/internal/server/follow.go b/internal/server/follow.go index 42d27dc5..1531fb1c 100644 --- a/internal/server/follow.go +++ b/internal/server/follow.go @@ -227,21 +227,31 @@ func (c *Server) followStep(host string, port int, followc int) error { } // Send the replication port to the leader - v, err := conn.Do("replconf", "listening-port", c.port) - if err != nil { - return err - } - if v.Error() != nil { - return v.Error() - } - if v.String() != "OK" { - return errors.New("invalid response to replconf request") - } - if core.ShowDebugMessages { - log.Debug("follow:", addr, ":replconf") + if err := func() error { + v, err := conn.Do("replconf", "listening-port", c.port) + if err != nil { + return err + } + if v.Error() != nil { + return v.Error() + } + if v.String() != "OK" { + return errors.New("invalid response to replconf request") + } + return nil + }(); err != nil { + if strings.HasPrefix(err.Error(), "ERR unknown command") { + log.Warn("follow:", addr, ":replconf", "not available on leader") + } else { + return err + } + } else { + if core.ShowDebugMessages { + log.Debug("follow:", addr, ":replconf") + } } - v, err = conn.Do("aof", pos) + v, err := conn.Do("aof", pos) if err != nil { return err }