ProxySQL 2.3 MySQL Group ReplicationProxySQL 2.3.0 was recently released and when I was reading the release notes, I was really impressed with the Group Replication enhancements and features. I thought of experimenting with those things and was interested to write a blog about them. Here, I have focused on the following two topics:

  • When the replication lag threshold is reached, ProxySQL will move the server to SHUNNED state, instead of moving them to OFFLINE hostgroup. When shunning a server, it will be performed gracefully and not immediately drop all backend connections.
  • The servers can be taken to maintenance through ProxySQL using “OFFLINE_SOFT”.

Test Environment

To test this, I have configured a three-node GR cluster (gr1,gr2,gr3) in my local environment. I have configured a single primary cluster (1 writer, 2 readers).

Currently, there is no transaction delay in the GR cluster.

To compare the result with older ProxySQL versions, I have configured two versions of ProxySQL. One is the latest version (2.3.0) and another one is the older version (2.2.2).

ProxySQL 1: (2.3.0)

ProxySQL 2: ( < 2.3.0 )

GR nodes are configured on both the ProxySQLs:

Host group settings are:

Scenario 1: When the replication lag threshold is reached, ProxySQL will move the server to SHUNNED state, instead of moving them to OFFLINE host group.

Here the replication lag threshold is configured when the ProxySQL is “20”.

As per my current setting,

  • At ProxySQL 2.3.0, if the transaction_behind reaches 20, then the node will be put into “SHUNNED” state.
  • At “< ProxySQL 2.3.0”, if the transaction_behind reaches 20, then the node will be put into an offline hostgroup.

To manually create the replication lag, I am going to start the read/write load on the GR cluster using the sysbench.

As expected, now I can see the transaction delay in the cluster.

Let’s see how the different ProxySQL versions are behaving now.

At ProxySQL 2.3.0:

As expected, both the reader nodes (gr2,gr3) are moved to “SHUNNED” state. And, the servers are still available in reader_hostgroup.

At “< ProxySQL 2.3.0”:

The server status is still ONLINE. But, the hostgroup_id is changed from 3 to 4. “4” is the offline hostgroup_id.

So, when comparing both the results, seems the latest release (2.3.0) has the correct implementation. Shunning the node is just temporarily taking the server out of use until the replication lag issue is fixed. When shunning a server, it will be performed gracefully and not immediately drop all backend connections. You can see the servers are still available in the reader hostgroups. With the previous implementation, the servers are moved to offline_hostgroup immediately.

Again, from ProxySQL 2.3.0, during the lag, shunning the nodes depend on the parameter “mysql-monitor_groupreplication_max_transactions_behind_for_read_only”. The parameter has 3 values (0,1,2).

  • “0” means only servers with “read_only=0” are placed as SHUNNED.
  • “1” means Only servers with “read_only=1” are placed as SHUNNED. This is the default one.
  • “2” means Both servers with “read_only=1” and “read_only=0” are placed as SHUNNED.

Scenario 2: The servers can be taken to maintenance through ProxySQL using “OFFLINE_SOFT”.

Personally, I would say, this is one of the nice implementations. From ProxySQL 2.3.0, ProxySQL itself can put the servers into the maintenance mode using the “OFFLINE_SOFT”. In the older version, you can also set it, but it was not stable. Let me explain the behavior of the latest and the older version.

Both ProxySQLs have the following configuration:

— Now, I am going to put the server “gr3” into maintenance mode on both ProxySQL.

After putting it into maintenance mode, both ProxySQL has the following output.

— Now, I am going to stop the group replication service on the “gr3”.

Let’s check the ProxySQL status now.

At ProxySQL 2.3.0:

The latest release still maintains the same status. “gr3” is still in maintenance mode.

At “< ProxySQL 2.3.0”:

The older ProxySQL release removed the “OFFLINE_SOFT” flag from “gr3” and put it on the offline hostgroup (hg 4).

— Now, I am again going to start the group_replication service on gr3.

At ProxySQL 2.3.0:

The latest release still maintains the same state.

At “< ProxySQL 2.3.0”:

At the older release, the server “gr3” came to ONLINE automatically. This is not the expected one because we did manually put that node into maintenance mode.

As you see in the comparison for the latest and older releases, the latest release has the right implementation. To remove the maintenance, we have to manually update the status to “ONLINE” as shown below.

I believe these two new implementations are very helpful to those who are running with the GR + ProxySQL setup. Apart from GR, the recent major releases have other important features as well. I will try to write a blog about them in the future, be on the lookout for that.

Complete the 2021 Percona Open Source Data Management Software Survey

Have Your Say!

Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments