Skip to content

Commit 5004118

Browse files
0xgoudapashagolub
authored andcommitted
[*] fix master only postgres source shutdown due to catched InRecovery state logic
move the shutdown code to the first `monitoredSource.IsInRecovery && monitoredSource.OnlyIfMaster` check and remove the later check becuase it will always be false
1 parent 86d95fc commit 5004118

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

internal/reaper/reaper.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,10 @@ func (r *Reaper) Reap(ctx context.Context) {
104104
srcL.WithField("recovery", monitoredSource.IsInRecovery).Infof("Connect OK. Version: %s", monitoredSource.VersionStr)
105105
if monitoredSource.IsInRecovery && monitoredSource.OnlyIfMaster {
106106
srcL.Info("not added to monitoring due to 'master only' property")
107+
if monitoredSource.IsPostgresSource() {
108+
srcL.Info("to be removed from monitoring due to 'master only' property and status change")
109+
hostsToShutDownDueToRoleChange[monitoredSource.Name] = true
110+
}
107111
continue
108112
}
109113

@@ -124,11 +128,7 @@ func (r *Reaper) Reap(ctx context.Context) {
124128
}
125129

126130
lastKnownStatusInRecovery := hostLastKnownStatusInRecovery[monitoredSource.Name]
127-
if monitoredSource.IsInRecovery && monitoredSource.OnlyIfMaster {
128-
srcL.Info("to be removed from monitoring due to 'master only' property and status change")
129-
hostsToShutDownDueToRoleChange[monitoredSource.Name] = true
130-
continue
131-
} else if lastKnownStatusInRecovery != monitoredSource.IsInRecovery {
131+
if lastKnownStatusInRecovery != monitoredSource.IsInRecovery {
132132
if monitoredSource.IsInRecovery && len(monitoredSource.MetricsStandby) > 0 {
133133
srcL.Warning("Switching metrics collection to standby config...")
134134
metricsConfig = monitoredSource.MetricsStandby

0 commit comments

Comments
 (0)