@@ -342,19 +342,29 @@ func (proxy *ProxySQLProxy) Refresh() error {
342
342
updated = true
343
343
}
344
344
345
- // if server is Standalone, set offline in ProxySQL
345
+ // if server is Standalone, and writer set offline in ProxySQL
346
346
if s .State == stateUnconn && bke .PrxStatus == "ONLINE" {
347
- cluster .LogPrintf (LvlInfo , "Monitor ProxySQL setting offline standalone server %s" , s .URL )
347
+ cluster .LogPrintf (LvlInfo , "Monitor ProxySQL setting writer offline standalone server %s" , s .URL )
348
348
err = psql .SetOffline (misc .Unbracket (s .Host ), s .Port )
349
349
if err != nil {
350
350
cluster .sme .AddState ("ERR00070" , state.State {ErrType : "WARNING" , ErrDesc : fmt .Sprintf (clusterError ["ERR00070" ], err , s .URL ), ErrFrom : "PRX" , ServerUrl : proxy .Name })
351
351
352
352
}
353
353
updated = true
354
354
355
+ } else if s .State == stateUnconn && bkeread .PrxStatus == "ONLINE" && isFoundBackendRead {
356
+ // if server is Standalone, and reader shunned it in ProxySQL
357
+ cluster .LogPrintf (LvlInfo , "Monitor ProxySQL setting reader offline standalone server %s" , s .URL )
358
+ err = psql .SetOfflineSoft (misc .Unbracket (s .Host ), s .Port )
359
+ if err != nil {
360
+ cluster .sme .AddState ("ERR00070" , state.State {ErrType : "WARNING" , ErrDesc : fmt .Sprintf (clusterError ["ERR00070" ], err , s .URL ), ErrFrom : "PRX" , ServerUrl : proxy .Name })
361
+ }
362
+ updated = true
363
+
364
+ } else if s .State == stateMaster && (s .PrevState == stateUnconn || s .PrevState == stateFailed || (len (proxy .BackendsWrite ) == 0 || ! isFoundBackendWrite )) {
355
365
// if the master comes back from a previously failed or standalone state, reintroduce it in
356
366
// the appropriate HostGroup
357
- } else if s . State == stateMaster && ( s . PrevState == stateUnconn || s . PrevState == stateFailed || ( len ( proxy . BackendsWrite ) == 0 || ! isFoundBackendWrite )) {
367
+
358
368
cluster .LogPrintf (LvlInfo , "Monitor ProxySQL setting online failed server %s" , s .URL )
359
369
if psql .ExistAsWriterOrOffline (misc .Unbracket (s .Host ), s .Port ) {
360
370
err = psql .SetOnline (misc .Unbracket (s .Host ), s .Port )
0 commit comments