Skip to content

Commit c06d4c8

Browse files
committed
Disbale switchober on minor release
1 parent 56a7b78 commit c06d4c8

File tree

8 files changed

+117
-37
lines changed

8 files changed

+117
-37
lines changed

cluster/cluster_chk.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,13 @@ func (cluster *Cluster) isSlaveElectableForSwitchover(sl *ServerMonitor, forcing
6969
hasBinLogs, err := cluster.IsEqualBinlogFilters(cluster.master, sl)
7070
if err != nil {
7171
if cluster.Conf.LogLevel > 1 || forcingLog {
72-
cluster.LogPrintf(LvlWarn, "Could not check binlog filters")
72+
cluster.LogPrintf(LvlWarn, "Could not check binlog filters on %s", sl.URL)
73+
}
74+
return false
75+
}
76+
if (!cluster.Conf.SwitchLowerRelease) && (sl.DBVersion.Major < cluster.master.DBVersion.Major || (sl.DBVersion.Major == cluster.master.DBVersion.Major && sl.DBVersion.Minor < cluster.master.DBVersion.Minor)) {
77+
if cluster.Conf.LogLevel > 1 || forcingLog {
78+
cluster.LogPrintf(LvlWarn, "Could not elect a minor version as leader without enabing switchover-lower-release %s", sl.URL)
7379
}
7480
return false
7581
}

cluster/cluster_job.go

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
// replication-manager - Replication Manager Monitoring and CLI for MariaDB and MySQL
2+
// Copyright 2017 Signal 18 Cloud SAS
3+
// Authors: Guillaume Lefranc <[email protected]>
4+
// Stephane Varoqui <[email protected]>
5+
// This source code is licensed under the GNU General Public License, version 3.
6+
7+
package cluster
8+
9+
import (
10+
"errors"
11+
12+
"github.com/signal18/replication-manager/utils/dbhelper"
13+
)
14+
15+
func (cluster *Cluster) JobAnalyzeSQL() error {
16+
var err error
17+
var logs string
18+
server := cluster.master
19+
20+
if server == nil {
21+
cluster.LogPrintf(LvlInfo, "Analyze tables cancel as no leader ")
22+
return errors.New("Analyze tables cancel as no leader")
23+
}
24+
if !cluster.Conf.MonitorSchemaChange {
25+
cluster.LogPrintf(LvlInfo, "Analyze tables cancel no schema monitor in config")
26+
return errors.New("Analyze tables cancel no schema monitor in config")
27+
}
28+
if cluster.inAnalyzeTables {
29+
cluster.LogPrintf(LvlInfo, "Analyze tables cancel already running")
30+
return errors.New("Analyze tables cancel already running")
31+
}
32+
if cluster.master.Tables == nil {
33+
cluster.LogPrintf(LvlInfo, "Analyze tables cancel no table list")
34+
return errors.New("Analyze tables cancel no table list")
35+
}
36+
cluster.inAnalyzeTables = true
37+
defer func() {
38+
cluster.inAnalyzeTables = false
39+
}()
40+
for _, t := range cluster.master.Tables {
41+
42+
// for _, s := range cluster.slaves {
43+
logs, err = dbhelper.AnalyzeTable(server.Conn, server.DBVersion, t.TableSchema+"."+t.TableName)
44+
cluster.LogSQL(logs, err, server.URL, "Monitor", LvlErr, "Could not get database variables %s %s", server.URL, err)
45+
46+
// cluster.LogPrintf(LvlInfo, "Analyse table %s on %s", t, s.URL)
47+
// }
48+
}
49+
return err
50+
}

cluster/cluster_tgl.go

+8-1
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,10 @@ func (cluster *Cluster) SwitchSchedulerDatabaseAnalyze() {
262262
cluster.SetSchedulerAnalyze()
263263
}
264264

265+
func (cluster *Cluster) SwitchSwitchLowerRelease() {
266+
cluster.Conf.SwitchLowerRelease = !cluster.Conf.SwitchLowerRelease
267+
}
268+
265269
func (cluster *Cluster) SwitchSchedulerRollingRestart() {
266270
cluster.Conf.SchedulerRollingRestart = !cluster.Conf.SchedulerRollingRestart
267271
cluster.SetSchedulerRollingRestart()
@@ -274,7 +278,6 @@ func (cluster *Cluster) SwitchSchedulerRollingReprov() {
274278

275279
func (cluster *Cluster) SwitchSchedulerAlertDisable() {
276280
cluster.Conf.SchedulerAlertDisable = !cluster.Conf.SchedulerAlertDisable
277-
278281
}
279282

280283
func (cluster *Cluster) SwitchGraphiteEmbedded() {
@@ -285,6 +288,10 @@ func (cluster *Cluster) SwitchGraphiteMetrics() {
285288
cluster.Conf.GraphiteMetrics = !cluster.Conf.GraphiteMetrics
286289
}
287290

291+
func (cluster *Cluster) SwitchFailoverLowerRelease() {
292+
cluster.Conf.SwitchLowerRelease = !cluster.Conf.SwitchLowerRelease
293+
}
294+
288295
func (cluster *Cluster) SwitchFailoverEventStatus() {
289296
cluster.Conf.FailEventStatus = !cluster.Conf.FailEventStatus
290297
}

config/config.go

+1
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ type Config struct {
149149
SwitchWaitTrx int64 `mapstructure:"switchover-wait-trx" toml:"switchover-wait-trx" json:"switchoverWaitTrx"`
150150
SwitchWaitWrite int `mapstructure:"switchover-wait-write-query" toml:"switchover-wait-write-query" json:"switchoverWaitWriteQuery"`
151151
SwitchGtidCheck bool `mapstructure:"switchover-at-equal-gtid" toml:"switchover-at-equal-gtid" json:"switchoverAtEqualGtid"`
152+
SwitchLowerRelease bool `mapstructure:"switchover-lower-release" toml:"switchover-lower-release" json:"switchoverLowerRelease"`
152153
SwitchSync bool `mapstructure:"switchover-at-sync" toml:"switchover-at-sync" json:"switchoverAtSync"`
153154
SwitchMaxDelay int64 `mapstructure:"switchover-max-slave-delay" toml:"switchover-max-slave-delay" json:"switchoverMaxSlaveDelay"`
154155
SwitchSlaveWaitCatch bool `mapstructure:"switchover-slave-wait-catch" toml:"switchover-slave-wait-catch" json:"switchoverSlaveWaitCatch"`

server/api_cluster.go

+2
Original file line numberDiff line numberDiff line change
@@ -995,6 +995,8 @@ func (repman *ReplicationManager) switchSettings(mycluster *cluster.Cluster, set
995995
mycluster.SwitchFailSync()
996996
case "force-slave-no-gtid-mode":
997997
mycluster.SwitchForceSlaveNoGtid()
998+
case "switchover-lower-release":
999+
mycluster.SwitchFailoverLowerRelease()
9981000
case "failover-event-status":
9991001
mycluster.SwitchFailoverEventStatus()
10001002
case "failover-event-scheduler":

server/server_monitor.go

+1
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ func init() {
127127
monitorCmd.Flags().BoolVar(&conf.SwitchoverCopyOldLeaderGtid, "switchover-copy-old-leader-gtid", false, "Switchover copy old leader GTID")
128128
monitorCmd.Flags().Int64Var(&conf.SwitchDecreaseMaxConnValue, "switchover-decrease-max-conn-value", 10, "Switchover decrease max connection to this value different according to flavor")
129129
monitorCmd.Flags().IntVar(&conf.SwitchSlaveWaitRouteChange, "switchover-wait-route-change", 2, "Switchover wait for unmanged proxy monitor to dicoverd new state")
130+
monitorCmd.Flags().BoolVar(&conf.SwitchLowerRelease, "switchover-lower-release", false, "Allow switchover to lower release")
130131
monitorCmd.Flags().StringVar(&conf.MasterConn, "replication-source-name", "", "Replication channel name to use for multisource")
131132
monitorCmd.Flags().StringVar(&conf.ReplicationMultisourceHeadClusters, "replication-multisource-head-clusters", "", "Multi source link to parent cluster, autodiscoverd but can be materialized for bootstraping replication")
132133
monitorCmd.Flags().StringVar(&conf.HostsDelayed, "replication-delayed-hosts", "", "Database hosts list that need delayed replication separated by commas")

share/dashboard/static/card-setting-replication.html

+36-8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<md-card>
22
<table ng-if="settings" class="table">
33
<tr>
4-
<th>Checks All Replication Constraint</th>
4+
<th>Checks failover & switchover constraints</th>
55
</tr>
66
<tr>
77
<td>
@@ -15,8 +15,13 @@
1515
</md-switch>
1616
</td>
1717
</tr>
18+
</table>
19+
</md-card>
20+
<BR>
21+
<md-card>
22+
<table ng-if="settings" class="table">
1823
<tr>
19-
<th>Failover Only On Semi-sync State Sync</th>
24+
<th>Failover only on semi-sync state is in sync</th>
2025
</tr>
2126
<tr>
2227
<td>
@@ -43,7 +48,7 @@
4348
</td>
4449
</tr>
4550
<tr>
46-
<th>Failover Using Positional Replication</th>
51+
<th>Failover using positional replication</th>
4752
</tr>
4853
<tr>
4954
<td>
@@ -59,7 +64,7 @@
5964
</td>
6065
</tr>
6166
<tr>
62-
<th>Failover Using Pseudo GTID</th>
67+
<th>Failover using pseudo GTID</th>
6368
</tr>
6469
<tr>
6570
<td>
@@ -74,8 +79,14 @@
7479
</md-switch>
7580
</td>
7681
</tr>
82+
</table>
83+
</md-card>
84+
<BR>
85+
<md-card>
86+
87+
<table ng-if="settings" class="table">
7788
<tr>
78-
<th>Switchover Only On Semi-sync State Sync</th>
89+
<th>Switchover only on semi-sync state in sync</th>
7990
</tr>
8091
<tr>
8192
<td>
@@ -91,7 +102,7 @@
91102
</td>
92103
</tr>
93104
<tr>
94-
<th>Switchover Replication Max Delay</th>
105+
<th>Switchover replication maximum delay</th>
95106
</tr>
96107
<tr>
97108
<td>
@@ -116,11 +127,28 @@
116127

117128
</td>
118129
</tr>
130+
<tr>
131+
<th>Switchover allow on minor release</th>
132+
</tr>
133+
<tr>
134+
<td>
135+
<md-switch ng-disabled="selectedCluster.apiUsers[user].grants['cluster-settings']==false" ng-true-value="true" ng-false-value="false" ng-model="selectedCluster.config.switchoverLowerRelease"
136+
ng-click="switchsettings('switchover-lower-release')"
137+
aria-label="Enforce read only on replicas">
138+
<span ng-if="selectedCluster.config.switchoverLowerRelease" class="label label-primary">On</span>
139+
<span ng-if="!selectedCluster.config.switchoverLowerRelease" class="label label-warning">Off</span>
140+
</md-switch>
141+
142+
</td>
143+
</tr>
119144
</table>
120-
<BR>
145+
</md-card>
146+
<BR>
147+
<md-card>
148+
121149
<table ng-if="settings" class="table">
122150
<tr>
123-
<th>Enforce Replication</th>
151+
<th>Enforce replication options</th>
124152
</tr>
125153
<tr>
126154
<td>

0 commit comments

Comments
 (0)