[CONJ-1118] Aurora Single Write Cluster Endpoint can't make Read DB Connection for readonly transaction Created: 2023-10-27  Updated: 2023-11-06  Resolved: 2023-11-06

Status: Closed
Project: MariaDB Connector/J
Component/s: 2.7 compatibility
Affects Version/s: 2.7.10
Fix Version/s: 2.7.11

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

aws aurora



 Description   

I am using AWS Aurora DB using a single write cluster endpoint. read only transaction is not executed in read db, but in write db.
Is the code below intended? It appears that the read db endpoint information obtained from write db cannot be used.

https://github.com/mariadb-corporation/mariadb-connector-j/blob/32df3852336f372a4d80011b1f0ab466623906a2/src/main/java/org/mariadb/jdbc/internal/protocol/AuroraProtocol.java#L186

"listener.getUrlParser().getHostAddresses()" always returns only the write cluster endpoint defined in the jdbc url string.

It seems that the code(inside if statement) below cannot be executed for the same reason as above.

            if (listener.getUrlParser().getHostAddresses().size() > 1) {
              // add newly discovered end-point to loop
              loopAddresses.addAll(listener.getUrlParser().getHostAddresses());
              // since there is more than one end point, reactivate connection to a read-only host
              searchFilter = new SearchFilter(false);
            }



 Comments   
Comment by Diego Dupin [ 2023-10-27 ]

Good point, the line before (https://github.com/mariadb-corporation/mariadb-connector-j/blob/32df3852336f372a4d80011b1f0ab466623906a2/src/main/java/org/mariadb/jdbc/internal/protocol/AuroraProtocol.java#L184) will update listener.hostAddresses will retreive all servers from command "select server_id, session_id from information_schema.replica_host_status where last_update_timestamp > now() - INTERVAL 3 MINUTE", but that will be used only AFTER trying to connect replica, not immediatly, using listener.getUrlParser().getHostAddresses() in place of something like listener.getHostAddresses()

Comment by Diego Dupin [ 2023-10-27 ]

Correction is simple, but I don't have access to aurora anymore.

Could you test the correction, available as SNAPSHOT ?

SNAPSHOTs are available adding sonatype snapshot repo, like:

<repositories>
    <repository>
        <id>sonatype-nexus-snapshots</id>
        <name>Sonatype Nexus Snapshots</name>
        <url>https://oss.sonatype.org/content/repositories/snapshots</url>
    </repository>
</repositories>
 
<dependencies>
    <dependency>
        <groupId>org.mariadb.jdbc</groupId>
        <artifactId>mariadb-java-client</artifactId>
        <version>2.7.11-SNAPSHOT</version>
    </dependency>
</dependencies>

Comment by choi heesung [ 2023-10-28 ]

thanks for reply.

I tested it. and it was working.
snapshot version driver makes 2 connections write db and read db.
Both write and read connections can be made with just a single write cluster endpoint.

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