Skip to content

Commit

Permalink
Resolve issues
Browse files Browse the repository at this point in the history
  • Loading branch information
noname0443 committed Sep 18, 2024
1 parent 872c27a commit 17005fd
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
11 changes: 2 additions & 9 deletions internal/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -1210,15 +1210,8 @@ func (app *App) performSwitchover(clusterState map[string]*NodeState, activeNode
// in case node is a master

if app.config.ForceSwitchover {
err := node.SetOffline()
if err != nil {
return fmt.Errorf("switchover: failed to set node %s offline: %v", host, err)
}

err = node.SemiSyncDisable()
if err != nil {
return fmt.Errorf("switchover: failed to disable semi-sync on node %s: %v", host, err)
}
node.SetOfflineForce()

Check failure on line 1213 in internal/app/app.go

View workflow job for this annotation

GitHub Actions / lint

Error return value of `node.SetOfflineForce` is not checked (errcheck)
defer node.SetOnline()

Check failure on line 1214 in internal/app/app.go

View workflow job for this annotation

GitHub Actions / lint

Error return value of `node.SetOnline` is not checked (errcheck)
}

err := node.SetReadOnly(true)
Expand Down
2 changes: 1 addition & 1 deletion internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ type Config struct {
ReplMonErrorWaitInterval time.Duration `config:"repl_mon_error_wait_interval" yaml:"repl_mon_error_wait_interval"`
ReplMonSlaveWaitInterval time.Duration `config:"repl_mon_slave_wait_interval" yaml:"repl_mon_slave_wait_interval"`
ShowOnlyGTIDDiff bool `config:"show_only_gtid_diff" yaml:"show_only_gtid_diff"`
ForceSwitchover bool `config:"force_switchover" yaml:"force_switchover"`
ForceSwitchover bool `config:"force_switchover" yaml:"force_switchover"` // TODO: Remove when we will be sure it's right way to do switchover
}

// DefaultConfig returns default configuration for MySync
Expand Down
14 changes: 14 additions & 0 deletions internal/mysql/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -833,6 +833,20 @@ func (n *Node) SetOnline() error {
return n.exec(queryDisableOfflineMode, nil)
}

func (n *Node) SetOfflineForce() error {
err := n.SemiSyncDisable()
if err != nil {
return fmt.Errorf("failed to disable semi-sync on node %s: %v", n.host, err)
}

err = n.SetOffline()
if err != nil {
return fmt.Errorf("failed to set node %s offline: %v", n.host, err)
}

return nil
}

// ChangeMaster changes master of MySQL Node, demoting it to slave
func (n *Node) ChangeMaster(host string) error {
useSsl := 0
Expand Down

0 comments on commit 17005fd

Please sign in to comment.