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

when only one slave and one master, connector/j only connect to master in some case

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open (View Workflow)
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 2.2.1
    • Fix Version/s: None
    • Component/s: aurora, Failover
    • Labels:
      None
    • Environment:
      AWS Aurora with 1 master node and 1 slave node

      Description

      In below scenarios, connector/j only connect to master at last.

      Scenario 1:
      1, Start aurora with 1 master node and 1 slave node.

      2, Start spring boot program using below URL to connect aurora.
      jdbc:mysql:aurora://xxx-cluster.cluster-yyy-zzz.rds.amazonaws.com/dbname
      Now we can set readOnly to true to access slave node, and set readOnly to false to access master node.

      3. Remove slave node from aurora cluster
      In this time, no matter what readOnly to set, the connector/j will access master node. It's OK.
      Sometimes, SQLException may happen when slave node is not removed completely.

      4. Add slave node into aurora cluster again.
      In this time, although setting readOnly to true, the connector/j still connect to master node.
      It's not OK. We want to connect slave node for read only connection.
      Now we can access slave node db from command line's mysql command.

      Scenario 2:
      1, Start aurora with only 1 master node.

      2, Start spring boot program using below URL to connect aurora.
      jdbc:mysql:aurora://xxx-cluster.cluster-yyy-zzz.rds.amazonaws.com/dbname
      Now no matter what readOnly to set, the connector/j will access master node. It's OK.

      3. Add slave node into aurora cluster again.
      In this time, although setting readOnly to true, the connector/j still connect to master node.
      It's not OK. We want to connect slave node for read only connection.
      We can access slave node db from command line's mysql command.

      Cause:
      In org.mariadb.jdbc.internal.protocol.AuroraProtocol#loop method, when only one slave and connect fail or no slave, it maybe not execute org.mariadb.jdbc.internal.failover.impl.AuroraListener#retrieveAllEndpointsAndSet to retrieve endpoints.

        Attachments

          Activity

            People

            Assignee:
            diego dupin Diego Dupin
            Reporter:
            donghui Hui Dong
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Dates

              Created:
              Updated:

                Git Integration