Skip to content

Commit 7a3a84e

Browse files
committed
backport of svar arbitrator fixes
Propagate runStatus to cluster after peer negotiation Rejoin code can be reached by a standby replication-manager
1 parent 72d7a16 commit 7a3a84e

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

arbitrator.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ import (
1515
_ "github.com/mattn/go-sqlite3"
1616

1717
log "github.com/Sirupsen/logrus"
18-
"github.com/spf13/cobra"
1918
"github.com/signal18/replication-manager/cluster"
2019
"github.com/signal18/replication-manager/dbhelper"
20+
"github.com/spf13/cobra"
2121
)
2222

2323
type route struct {
@@ -294,6 +294,10 @@ func fHeartbeat() {
294294
currentCluster.LogPrintf("DEBUG", "Peer node is Active, I am Standby")
295295
runStatus = "S"
296296
}
297+
// propagate all runStatus to clusters after peer negotiation
298+
for _, cl := range clusters {
299+
cl.SetActiveStatus(runStatus)
300+
}
297301
}
298302

299303
}

cluster/monitor.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ func (server *ServerMonitor) check(wg *sync.WaitGroup) {
290290
}
291291
server.State = stateUnconn
292292
server.FailCount = 0
293-
if server.ClusterGroup.conf.Autorejoin {
293+
if server.ClusterGroup.conf.Autorejoin && server.ClusterGroup.IsActive() {
294294
server.RejoinMaster()
295295
} else {
296296
server.ClusterGroup.LogPrintf("INFO", "Auto Rejoin is disabled")
@@ -307,7 +307,7 @@ func (server *ServerMonitor) check(wg *sync.WaitGroup) {
307307
server.PrevState = server.State
308308
}
309309
return
310-
} else if errss == nil && (server.PrevState == stateFailed || server.PrevState == stateSuspect) {
310+
} else if server.ClusterGroup.IsActive() && errss == nil && (server.PrevState == stateFailed || server.PrevState == stateSuspect) {
311311
server.rejoinSlave(ss)
312312
}
313313

0 commit comments

Comments
 (0)