Skip to content

Commit

Permalink
Merge pull request #530 from ahfa92/proxysql
Browse files Browse the repository at this point in the history
Make Error for Proxy more informative
  • Loading branch information
svaroqui committed Jan 3, 2024
2 parents 86f3c1e + 88e3f2d commit 81ca897
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
4 changes: 2 additions & 2 deletions cluster/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ var clusterError = map[string]string{
"ERR00068": "Arbitration looser",
"ERR00069": "ProxySQL could not set %s as reader (%s) different state OFFLINE_HARD",
"ERR00070": "ProxySQL could not set %s as reader (%s) different state ONLINE",
"ERR00071": "ProxySQL could not set discoverd master %s as writer (%s)",
"ERR00072": "ProxySQL could not set discoverd slave %s as reader (%s)",
"ERR00071": "ProxySQL %s could not set discoverd master %s as writer (%s)",
"ERR00072": "ProxySQL %s could not set discoverd slave %s as reader (%s)",
"ERR00073": "Could not get events on server %s",
"ERR00074": "Prefered server %s not found in configured server list",
"ERR00075": "Can't fecth Processlist %s",
Expand Down
7 changes: 5 additions & 2 deletions cluster/prx_janitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,11 @@ func (proxy *ProxyJanitor) Refresh() error {
if s.GetPrevState() == stateUnconn || s.GetPrevState() == stateFailed || (len(proxy.BackendsWrite) == 0 || !isFoundBackendWrite) {
// if the proxy comes back from a previously failed or standalone state, reintroduce it in
// the appropriate HostGroup

cluster.StateMachine.AddState("ERR00071", state.State{ErrType: "WARNING", ErrDesc: fmt.Sprintf(clusterError["ERR00071"], err, s.GetURL()), ErrFrom: "PRX", ServerUrl: proxy.Name})
errstr := ""
if err != nil {
errstr = err.Error()
}
cluster.StateMachine.AddState("ERR00071", state.State{ErrType: "WARNING", ErrDesc: fmt.Sprintf(clusterError["ERR00071"], proxy.Name, s.GetURL(), errstr), ErrFrom: "PRX", ServerUrl: proxy.Name})
if psql.ExistAsWriterOrOffline(misc.Unbracket(s.GetHost()), strconv.Itoa(s.GetWritePort())) {
err = psql.SetOnline(misc.Unbracket(s.GetHost()), strconv.Itoa(s.GetWritePort()))
if err != nil {
Expand Down
9 changes: 6 additions & 3 deletions cluster/prx_proxysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -364,8 +364,11 @@ func (proxy *ProxySQLProxy) Refresh() error {
} else if s.IsLeader() && (s.PrevState == stateUnconn || s.PrevState == stateFailed || (len(proxy.BackendsWrite) == 0 || !isFoundBackendWrite)) {
// if the master comes back from a previously failed or standalone state, reintroduce it in
// the appropriate HostGroup

cluster.StateMachine.AddState("ERR00071", state.State{ErrType: "WARNING", ErrDesc: fmt.Sprintf(clusterError["ERR00071"], err, s.URL), ErrFrom: "PRX", ServerUrl: proxy.Name})
errstr := ""
if err != nil {
errstr = err.Error()
}
cluster.StateMachine.AddState("ERR00071", state.State{ErrType: "WARNING", ErrDesc: fmt.Sprintf(clusterError["ERR00071"], proxy.Name, s.URL, errstr), ErrFrom: "PRX", ServerUrl: proxy.Name})
if psql.ExistAsWriterOrOffline(misc.Unbracket(s.Host), s.Port) {
err = psql.SetOnline(misc.Unbracket(s.Host), s.Port)
if err != nil {
Expand Down Expand Up @@ -406,7 +409,7 @@ func (proxy *ProxySQLProxy) Refresh() error {
cluster.LogPrintf(LvlInfo, "Monitor ProxySQL setting reader standalone server %s", s.URL)
}
if err != nil {
cluster.StateMachine.AddState("ERR00072", state.State{ErrType: "WARNING", ErrDesc: fmt.Sprintf(clusterError["ERR00072"], err, s.URL), ErrFrom: "PRX", ServerUrl: proxy.Name})
cluster.StateMachine.AddState("ERR00072", state.State{ErrType: "WARNING", ErrDesc: fmt.Sprintf(clusterError["ERR00072"], proxy.Name, s.URL, err), ErrFrom: "PRX", ServerUrl: proxy.Name})
}
updated = true
} else if s.IsSlaveOrSync() && !isFoundBackendRead && !s.IsIgnored() {
Expand Down

0 comments on commit 81ca897

Please sign in to comment.