1
votes

We're testing the failover behaviour using the MariaDB JDBC connector Aurora specific features.

We've set the JDBC URL as the documentation suggest:

jdbc:mysql:aurora://cluster.cluster-xxxx.us-east-1.rds.amazonaws.com/db

The problem is that as soon as we add the aurora: part in the URL schema, we can see an increase in the connections to the database writer until the point that we've to rollback the change (it even reaches 3.000 connections).

Versions:

Configuration:

master {
  profile = "slick.jdbc.MySQLProfile$"
  db {
    driver = "org.mariadb.jdbc.Driver"
    url = "jdbc:mysql:aurora://cluster-name.cluster-xxx.us-east-1.rds.amazonaws.com/db_name?characterEncoding=utf8mb4&rewriteBatchedStatements=true&usePipelineAuth=false"
    user = "rw_user"
    password = "rw_user_pass"
    numThreads = 20
    queueSize = 1000000
  }
}
slaves = [
  {
    profile = "slick.jdbc.MySQLProfile$"
    db {
      driver = "org.mariadb.jdbc.Driver"
      url = "jdbc:mysql:aurora://cluster-name.cluster-ro-xxx.us-east-1.rds.amazonaws.com/db_name?characterEncoding=utf8mb4&usePipelineAuth=false"
      user = "ro_user"
      password = "ro_user_pass"
      numThreads = 20
      queueSize = 1000000
    }
  }
]

We'd tried to add the aurora: part to the JDBC URL schema after upgrading the MariaDB connector version, but the number of connections to the Reader started to increase again:

If we run a show processlist on the read only endpoint, we can see all the opened connections in "cleaned up" state, and "Sleep" command.

We'd removed the aurora: part from the read only endpoint just in order to stabilize the number of connections to it. Is it possible that the driver searches for the cluster master while opening connections? That would explain this kind of behaviour.

2
(Mariadb tracker link is jira.mariadb.org/projects/CONJ/issues)Diego Dupin
can you execute a "show processlist" to list those multiple connections and their states ?Diego Dupin
@DiegoDupin, thanks for your help. I've edited the question providing more details about the issue including the connections status.JavierCane
@JavierCane were you ever able to figure this out? It's been a few years, and I'm running into this same problemJPotts

2 Answers

2
votes

When using the "aurora" keyword, driver , under the hood, create 2 connections:

  • a connection to the primary server,
  • a connection to one of the replicas if any.

The goal is always to save resources on the main server. Generally, only one pool is configured. The driver then uses the connection to the primary / replica according to [Connection.setReadOnly] [1].

When you have separate "write" / "read" pools, using the configuration "failover" will solve your issue: Driver will use only one real connection. This way, there will be no "wasted" connection.

Failover will then be handled differently, but with the same results (for example, a query not in a transaction that is to be sent to a replica that just crashed will not directly use the primary connection as when using the "aurora" configuration, the driver will recreate a new connection to another replicas before executing the query).

1
votes

Once you get past several dozen active connections, the database starts stumbling over itself. It is better to throttle the connections in the client instead of assuming you have infinite bandwidth to accept connections in Aurora.