Skip to content

Commit

Permalink
feat: making sure that the node has switched to read_only mode (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
Fizic authored Jun 21, 2023
1 parent f8cf6a1 commit cf604f4
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion internal/mysql/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,23 @@ func (n *Node) setReadonlyWithTimeout(superReadOnly bool, timeout time.Duration)
query = querySetReadonlyNoSuper
}

return n.execWithTimeout(query, nil, timeout)
err := n.execWithTimeout(query, nil, timeout)
if err != nil {
return err
}

// making sure that the node has switched to read_only mode
isReadOnly, isSuperReadOnly, err := n.IsReadOnly()
if err != nil {
return err
}
if isSuperReadOnly != superReadOnly {
return fmt.Errorf("the node has not switched to super_read_only mode")
}
if !isReadOnly {
return fmt.Errorf("the node has not switched to read_only mode")
}
return nil
}

// SetReadOnlyWithForce sets MySQL Node to be read-only
Expand Down

0 comments on commit cf604f4

Please sign in to comment.