[MXS-1743] Maxscale unable to enforce round-robin between read service for Slave Created: 2018-03-27  Updated: 2020-08-25  Resolved: 2018-06-04

Status: Closed
Project: MariaDB MaxScale
Component/s: readconnroute
Affects Version/s: 2.2, 2.2.3
Fix Version/s: 2.2.9

Type: Bug Priority: Critical
Reporter: Pramod Mahto Assignee: markus makela
Resolution: Fixed Votes: 0
Labels: None
Environment:

CentOS , MaxScale


Attachments: File maxscale.cnf     Text File router_options=master,slave.txt     Text File router_options=slave.txt    

 Description   

With the router_options set to slave,master , accessing node gives an error below "MySQL server has gone away" [Master & Slave node are up and running].

 
[root@maxscale ~]# maxadmin
MaxScale> list servers
Servers.
-------------------+-----------------+-------+-------------+--------------------
Server             | Address         | Port  | Connections | Status
-------------------+-----------------+-------+-------------+--------------------
master-node        | 192.168.207.207 |  3306 |           0 | Master, Running
slave-node         | 192.168.207.206 |  3306 |           0 | Slave, Running
-------------------+-----------------+-------+-------------+--------------------
MaxScale>
 
 
[root@maxscale ~]# mysql -u maxmon -pmaxmon  -h 192.168.207.158 -e "select @@hostname" --port=3399
ERROR 2006 (HY000) at line 1: MySQL server has gone away

If Slave-node is stop (Service mysql stop) then all read queries are directing to the master-node.

 
[root@maxscale ~]# maxadmin
MaxScale> list servers
Servers.
-------------------+-----------------+-------+-------------+--------------------
Server             | Address         | Port  | Connections | Status
-------------------+-----------------+-------+-------------+--------------------
master-node        | 192.168.207.207 |  3306 |           0 | Master, Running
slave-node         | 192.168.207.206 |  3306 |           0 | Down
-------------------+-----------------+-------+-------------+--------------------
 
 
[root@maxscale ~]#  mysql -u maxmon -pmaxmon  -h 192.168.207.158 -e "select @@hostname" --port=3399
+-------------+
| @@hostname  |
+-------------+
| master-node |
+-------------+

When we remove the slave option from the router_options i.e router_options=master then it only goes to the Master (Which is as expected )

 
MaxScale> list servers
Servers.
-------------------+-----------------+-------+-------------+--------------------
Server             | Address         | Port  | Connections | Status
-------------------+-----------------+-------+-------------+--------------------
master-node        | 192.168.207.207 |  3306 |           0 | Master, Running
slave-node         | 192.168.207.206 |  3306 |           0 | Slave, Running
-------------------+-----------------+-------+-------------+--------------------
 
[root@maxscale ~]#  mysql -u maxmon -pmaxmon  -h 192.168.207.158 -e "select @@hostname" --port=3399
+-------------+
| @@hostname  |
+-------------+
| master-node |
+-------------+

When we remove the master option from the router_options i.e router_options=slave then it only goes to the Slave (Which is as expected )

 
[root@maxscale ~]# maxadmin
MaxScale> list servers
Servers.
-------------------+-----------------+-------+-------------+--------------------
Server             | Address         | Port  | Connections | Status
-------------------+-----------------+-------+-------------+--------------------
master-node        | 192.168.207.207 |  3306 |           0 | Master, Running
slave-node         | 192.168.207.206 |  3306 |           0 | Slave, Running
-------------------+-----------------+-------+-------------+--------------------
 
 
[root@maxscale ~]# mysql -u maxmon -pmaxmon  -h 192.168.207.158 -e "select @@hostname" --port=3399
+------------+
| @@hostname |
+------------+
| slave-node |
+------------+

Is there a way that will enforce a round-robin between Master-node and Slave-Node?

 



 Comments   
Comment by markus makela [ 2018-04-04 ]

router_options=master,slave now works correctly.

Comment by Pramod Mahto [ 2018-06-04 ]

With router_options=master,slave , still its not working as expected .

Tested with Maxscale 2.2.5 and 2.2.6

Read-Service]
type=service
router=readconnroute
router_options=master,slave
servers=master-node,slave-node-01,slave-node-02
user=maxmon
passwd=maxmon
#localhost_match_wildcard_host=1

Then it should enforce round-robin between Master and Slave node i.e. servers=master-node,slave-node-01,slave-node-02 which is not working as expected , all connection goes to only master-node

[Read-Service]
type=service
router=readconnroute
router_options=slave
servers=master-node,slave-node-01,slave-node-02
user=maxmon
passwd=maxmon
#localhost_match_wildcard_host=1

then it enforce the round-robin between only Slave server i.e between slave-node-01,slave-node-02.
router_options=slave.txt router_options=master,slave.txt

Comment by markus makela [ 2018-06-04 ]

The load balancing algorithm mistook the master server as the only valid candidate when router_options=master,slave was defined. The correct way to do it is to check if router_options=master is explicitly specified (in other words, no other types of servers are allowed).

Generated at Thu Feb 08 04:09:04 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.