Uploaded image for project: 'MariaDB Connector/J'
  1. MariaDB Connector/J
  2. CONJ-395

Aurora does not randomise selection of read replicas

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.5.4, 1.5.5
    • Fix Version/s: 1.5.6
    • Component/s: Failover
    • 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).

        Attachments

          Activity

            People

            Assignee:
            diego dupin Diego Dupin
            Reporter:
            mattbreeze Matthew Breeze
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Git Integration