Skip to content

Commit

Permalink
fix: enabling semisync; feat: errno in logs
Browse files Browse the repository at this point in the history
  • Loading branch information
Fizic committed May 22, 2024
1 parent 92c21e2 commit 8a1f02f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
12 changes: 11 additions & 1 deletion internal/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,12 @@ func (app *App) checkRecovery() {
app.logger.Infof("recovery: local node %s has GTIDs %s", localNode.Host(), sstatus.GetExecutedGtidSet())

if isSlavePermanentlyLost(sstatus, mgtids) {
app.logger.Errorf("recovery: local node %s is NOT behind the master %s, need RESETUP", localNode.Host(), masterNode)
rp, err := localNode.GetReplicaStatus()
if err != nil {
app.logger.Errorf("recovery: local node %s is NOT behind the master %s, need RESETUP", localNode.Host(), masterNode)
} else {
app.logger.Errorf("recovery: local node %s is NOT behind the master %s, need RESETUP, last IO errno: %d", localNode.Host(), masterNode, rp.GetLastIOErrno())
}
app.writeResetupFile("")
} else {
readOnly, _, err := localNode.IsReadOnly()
Expand Down Expand Up @@ -1072,6 +1077,11 @@ func (app *App) enableSemiSyncOnSlave(host string) error {
app.logger.Errorf("failed restart slave io thread after set semi_sync_slave on %s: %s", host, err)
return err
}
err = node.RestartReplication()
if err != nil {
app.logger.Errorf("failed restart replication after set semi_sync_slave on %s: %s", host, err)
return err
}
return nil
}

Expand Down
11 changes: 10 additions & 1 deletion internal/mysql/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -722,6 +722,15 @@ func (n *Node) StartSlave() error {
})
}

// RestartReplication restart replication
func (n *Node) RestartReplication() error {
err := n.StopSlave()
if err != nil {
return err
}
return n.StartSlave()
}

// StopSlaveIOThread stops IO replication thread
func (n *Node) StopSlaveIOThread() error {
return n.execMogrify(queryStopSlaveIOThread, map[string]interface{}{
Expand All @@ -736,7 +745,7 @@ func (n *Node) StartSlaveIOThread() error {
})
}

// RestartSlaveIOThread stops IO replication thread
// RestartSlaveIOThread restart IO replication thread
func (n *Node) RestartSlaveIOThread() error {
err := n.StopSlaveIOThread()
if err != nil {
Expand Down

0 comments on commit 8a1f02f

Please sign in to comment.