mirror of
https://github.com/datarhei/core.git
synced 2025-10-25 00:40:38 +08:00
Make emergency leadership only available in a cluster with two nodes
This commit is contained in:
@@ -1697,6 +1697,11 @@ func (c *cluster) sentinel() {
|
|||||||
"num_peers": stats.NumPeers,
|
"num_peers": stats.NumPeers,
|
||||||
}).Log("Stats")
|
}).Log("Stats")
|
||||||
|
|
||||||
|
if stats.NumPeers > 1 {
|
||||||
|
// Enable emergency leadership only in a configuration with two nodes.
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
if stats.LastContact > c.emergencyLeaderTimeout && !isEmergencyLeader {
|
if stats.LastContact > c.emergencyLeaderTimeout && !isEmergencyLeader {
|
||||||
c.logger.Warn().Log("Force leadership due to lost contact to leader")
|
c.logger.Warn().Log("Force leadership due to lost contact to leader")
|
||||||
c.raftEmergencyNotifyCh <- true
|
c.raftEmergencyNotifyCh <- true
|
||||||
|
|||||||
@@ -348,10 +348,7 @@ func (c *cluster) synchronizeAndRebalance(ctx context.Context, interval time.Dur
|
|||||||
}
|
}
|
||||||
|
|
||||||
c.doSynchronize(emergency)
|
c.doSynchronize(emergency)
|
||||||
|
c.doRebalance(emergency)
|
||||||
if !emergency {
|
|
||||||
c.doRebalance(emergency)
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
c.doSynchronize(emergency)
|
c.doSynchronize(emergency)
|
||||||
}
|
}
|
||||||
@@ -588,6 +585,11 @@ func (c *cluster) doSynchronize(emergency bool) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *cluster) doRebalance(emergency bool) {
|
func (c *cluster) doRebalance(emergency bool) {
|
||||||
|
if emergency {
|
||||||
|
// Don't rebalance in emergency mode
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
have := c.proxy.ListProxyProcesses()
|
have := c.proxy.ListProxyProcesses()
|
||||||
nodes := c.proxy.ListNodes()
|
nodes := c.proxy.ListNodes()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user