Skip to content

Commit e90d789

Browse files
committed
Errant trx printed when replication is up to date #540
1 parent 5d7bdc3 commit e90d789

File tree

4 files changed

+7
-1
lines changed

4 files changed

+7
-1
lines changed

cluster/cluster_chk.go

+4
Original file line numberDiff line numberDiff line change
@@ -708,10 +708,14 @@ func (cluster *Cluster) IsNotHavingMySQLErrantTransaction() bool {
708708
if !(cluster.GetMaster().HasMySQLGTID()) {
709709
return true
710710
}
711+
if !cluster.Conf.RplCheckErrantTrx {
712+
return true
713+
}
711714
for _, s := range cluster.slaves {
712715
if s.IsFailed() || s.IsIgnored() {
713716
continue
714717
}
718+
715719
hasErrantTrx, _, _ := dbhelper.HaveErrantTransactions(s.Conn, cluster.master.Variables["GTID_EXECUTED"], s.Variables["GTID_EXECUTED"])
716720
if hasErrantTrx {
717721
cluster.SetState("WARN0091", state.State{ErrType: LvlWarn, ErrDesc: fmt.Sprintf(clusterError["WARN0091"], s.URL), ErrFrom: "MON", ServerUrl: s.URL})

config/config.go

+1
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ type Config struct {
217217
CheckBinFilter bool `mapstructure:"check-binlog-filters" toml:"check-binlog-filters" json:"checkBinlogFilters"`
218218
CheckGrants bool `mapstructure:"check-grants" toml:"check-grants" json:"checkGrants"`
219219
RplChecks bool `mapstructure:"check-replication-state" toml:"check-replication-state" json:"checkReplicationState"`
220+
RplCheckErrantTrx bool `mapstructure:"check-replication-errant-trx" toml:"check-replication-errant-trx" json:"checkReplicationErrantTrx"`
220221
ForceSlaveHeartbeat bool `mapstructure:"force-slave-heartbeat" toml:"force-slave-heartbeat" json:"forceSlaveHeartbeat"`
221222
ForceSlaveHeartbeatTime int `mapstructure:"force-slave-heartbeat-time" toml:"force-slave-heartbeat-time" json:"forceSlaveHeartbeatTime"`
222223
ForceSlaveHeartbeatRetry int `mapstructure:"force-slave-heartbeat-retry" toml:"force-slave-heartbeat-retry" json:"forceSlaveHeartbeatRetry"`

server/server.go

+1
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,7 @@ func (repman *ReplicationManager) AddFlags(flags *pflag.FlagSet, conf *config.Co
379379
flags.BoolVar(&conf.CheckBinFilter, "check-binlog-filters", true, "Check that possible master have equal binlog filters")
380380
flags.BoolVar(&conf.CheckGrants, "check-grants", true, "Check that possible master have equal grants")
381381
flags.BoolVar(&conf.RplChecks, "check-replication-state", true, "Check replication status when electing master server")
382+
flags.BoolVar(&conf.RplCheckErrantTrx, "check-replication-errant-trx", true, "Check replication have no errant transaction in MySQL GTID")
382383

383384
flags.StringVar(&conf.APIPort, "api-port", "10005", "Rest API listen port")
384385
flags.StringVar(&conf.APIUsers, "api-credentials", "admin:repman", "Rest API user list user:password,..")

utils/dbhelper/mysql.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
func HaveErrantTransactions(db *sqlx.DB, gtidMaster string, gtidSlave string) (bool, string, error) {
1010

1111
count := 0
12-
query := "select gtid_subset('" + gtidMaster + "','" + gtidSlave + "') as slave_is_subset"
12+
query := "select gtid_subset('" + gtidSlave + "','" + gtidMaster + "') as slave_is_subset"
1313

1414
err := db.QueryRowx(query).Scan(&count)
1515
if err != nil {

0 commit comments

Comments
 (0)