From cf604f43d9ca098c65eca6e95d11b0791f0dc774 Mon Sep 17 00:00:00 2001 From: Firsov Kirill <37708382+Fizic@users.noreply.github.com> Date: Wed, 21 Jun 2023 12:43:27 +0300 Subject: [PATCH] feat: making sure that the node has switched to read_only mode (#23) --- internal/mysql/node.go | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/internal/mysql/node.go b/internal/mysql/node.go index 7001c4b1..0e5dc2a6 100644 --- a/internal/mysql/node.go +++ b/internal/mysql/node.go @@ -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