Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
1.5.4, 1.5.5
-
None
-
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).