Skip to content

Commit

Permalink
feat(dbm-services): dbha should check slave's master_host close #8474
Browse files Browse the repository at this point in the history
  • Loading branch information
xjxia authored and iSecloud committed Dec 12, 2024
1 parent 51ece3e commit 4771f6f
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ type MySQLVariableInfo struct {

// BinlogStatus binlog status info struct
type BinlogStatus struct {
MasterHost string
MasterPort int
MasterLogFileIndex int
RelayMasterLogFileIndex int
ReadMasterLogPos uint64
Expand Down Expand Up @@ -536,6 +538,11 @@ func (ins *MySQLCommonSwitch) CheckSlaveSlow(ignoreDelay bool) error {
log.Logger.Infof("Relay_Master_Log_File_Index:%d, Exec_Master_Log_Pos:%d",
status.RelayMasterLogFileIndex, status.ReadMasterLogPos)

if status.MasterHost != ins.Ip || status.MasterPort != ins.Port {
return fmt.Errorf("slave status's master info[%s#%d] not equal broken-down instance[%s#%d]",
status.MasterHost, status.MasterPort, ins.Ip, ins.Port)
}

if ignoreDelay {
log.Logger.Infof("ignore delay check configured, skip check replication delay")
return nil
Expand Down Expand Up @@ -614,6 +621,8 @@ func GetSlaveStatus(db *gorm.DB) (BinlogStatus, error) {
return BinlogStatus{}, err
}

ret.MasterHost = slaveStatus.MasterHost
ret.MasterPort = slaveStatus.MasterPort
ret.ReadMasterLogPos = slaveStatus.ReadMasterLogPos
ret.ExecMasterLogPos = slaveStatus.ExecMasterLogPos
// ret.RetrievedGtidSet = slaveStatus.RetrievedGtidSet
Expand Down

0 comments on commit 4771f6f

Please sign in to comment.