Databases 7 min read

Read SQL Routed to Master Despite rwSplitMode=3 Configuration

The article investigates why read queries are sent to the master node when Dble is configured with rwSplitMode=3, analyzes reproductions on standard replication and MySQL Group Replication, identifies heartbeat and replication status issues, and provides troubleshooting steps and recommendations.

Aikesheng Open Source Community
Aikesheng Open Source Community
Aikesheng Open Source Community
Read SQL Routed to Master Despite rwSplitMode=3 Configuration

The article investigates a community‑reported issue where read‑only SQL statements were consistently routed to the master instance despite configuring rwSplitMode=3 in the Dble middleware.

Background: A user observed that, regardless of the rwSplitMode value, queries were always sent to the primary node. Processlist checks confirmed the absence of queries on the slave nodes.

Local Reproduction I : In a pure read/write split test environment, SELECT statements were correctly dispatched to the slave, as shown by screenshots of the test setup.

The db.xml configuration displayed rwSplitMode=3 and a heartbeat SQL of show slave status with delayThreshold="100" .

Potential causes considered were: (1) abnormal heartbeat on the slave ( show @@heartbeat ), (2) replication status errors ( show slave status ), and (3) replication delay exceeding the configured threshold ( Seconds_Behind_Master ).

A follow‑up question asked what heartbeat SQL should be used when the backend connects to MySQL Group Replication (MGR). An initial hypothesis linked the problem to MySQL versions ≥ 8.0.26, but later tests disproved this.

Local Reproduction II : Using MySQL 8.0.26 standard master‑slave replication, heartbeat was normal, no errors appeared in dble.log , and read queries were correctly sent to the slave.

Local Reproduction III : When the backend was switched to a three‑node MGR cluster, both read and write SQL were routed to the primary. The configuration still used show slave status as the heartbeat, which returns empty in MGR mode, leading to log errors such as "found MySQL master/slave Replication err" and causing reads to fall back to the master.

Summary of troubleshooting steps: verify expected behavior for the specific Dble version, check heartbeat status, examine the output of show slave status , consider delay detection parameters, and be aware of possible backend instance stickiness in newer Dble releases (e.g., 3.22.01.0).

Regarding Dble’s support for group replication, the recommendation is not to use show slave status as the heartbeat SQL in MGR environments because it yields no result, which prevents proper replication health checks and triggers the aforementioned errors.

The article concludes by thanking the community user for reporting the issue and the Dble developers for their systematic analysis.

MySQLDatabase MiddlewareRead-Write SplittingTroubleshootingGroup ReplicationDBLE
Aikesheng Open Source Community
Written by

Aikesheng Open Source Community

The Aikesheng Open Source Community provides stable, enterprise‑grade MySQL open‑source tools and services, releases a premium open‑source component each year (1024), and continuously operates and maintains them.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.