[CONJ-395] Aurora does not randomise selection of read replicas Created: 2016-12-02  Updated: 2016-12-14  Resolved: 2016-12-12

Status: Closed
Project: MariaDB Connector/J
Component/s: Failover
Affects Version/s: 1.5.4, 1.5.5
Fix Version/s: 1.5.6

Type: Bug Priority: Major
Reporter: Matthew Breeze Assignee: Diego Dupin
Resolution: Fixed Votes: 0
Labels: None
Environment:

Windows/Linux



 Description   

Given an Aurora cluster of one master and 2 read replicas, when creating a connection using Maria Connector/J and passing the master endpoint as URL, the connector will make one connection to the master and only ever connect to one of the read replicas, rather than randomly selecting one for load balancing.

The documentation suggests that random picking connection initialization is the default for Aurora:
https://mariadb.com/kb/en/mariadb/failover-and-high-availability-with-mariadb-connector-j/

Root cause:
It seems that within the loop method of AuroraProtocol.java:167 the read replicas are added in the order obtained from querying INFORMATION_SCHEMA.REPLICA_HOST_STATUS from the master endpoint, which is not randomized.

Potential fix:
This can be fixed by either randomizing the order they are inserted in the loop method, or randomizing the order that they are initially queried (e.g. ordering by the REPLICA_LAG_IN_MILLISECONDS in the query in getCurrentEndpointIdentifiers in AuroraListener.java:252).



 Comments   
Comment by Diego Dupin [ 2016-12-12 ]

Confirmed, regression corrected with commit : https://github.com/MariaDB/mariadb-connector-j/commit/a84d69d9fc783baed430fb4bc402b62f00bb367c

correction will i7n in 1.5.6 ( during the weak).

Generated at Thu Feb 08 03:15:21 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.