From e665b3710c7c609bb61f6d5de1fccb5c5912ace3 Mon Sep 17 00:00:00 2001 From: Sugu Sougoumarane Date: Thu, 13 Aug 2020 14:09:26 -0700 Subject: [PATCH] tm: minor logging fix replmanager never logged the first failure due to bad initilization. Signed-off-by: Sugu Sougoumarane --- go/vt/vttablet/tabletmanager/replmanager.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/go/vt/vttablet/tabletmanager/replmanager.go b/go/vt/vttablet/tabletmanager/replmanager.go index d457f1485f2..c80f3c3de8f 100644 --- a/go/vt/vttablet/tabletmanager/replmanager.go +++ b/go/vt/vttablet/tabletmanager/replmanager.go @@ -43,11 +43,11 @@ const ( // the tabletserver state. This will ensure that replication is fixed // upfront, allowing tabletserver to start off healthy. type replManager struct { - ctx context.Context - tm *TabletManager - markerFile string - ticks *timer.Timer - firstFailure bool + ctx context.Context + tm *TabletManager + markerFile string + ticks *timer.Timer + failed bool // replStopped is tri-state. // A nil value signifies that the value is not set. @@ -113,20 +113,20 @@ func (rm *replManager) checkActionLocked() { } } - if rm.firstFailure { + if !rm.failed { log.Infof("Replication is stopped, reconnecting to master.") } ctx, cancel := context.WithTimeout(rm.ctx, 5*time.Second) defer cancel() if err := rm.tm.repairReplication(ctx); err != nil { - if rm.firstFailure { - rm.firstFailure = false + if !rm.failed { + rm.failed = true log.Infof("Failed to reconnect to master: %v, will keep retrying.", err) } return } log.Info("Successfully reconnected to master.") - rm.firstFailure = true + rm.failed = false } // setReplicationStopped performs a best effort attempt of