failoverMode
for read-only cluster endpoint is unexpectedly set to strict-writer
#1199
Labels
bug
Something isn't working
Describe the bug
When connecting to a read-only cluster endpoint with the
failover2
plugin and without thefailoverMode
property, it appears thatfailoverMode
defaults tostrict-writer
.As a result, when a cluster failover occurs, the
failover2
plugin establishes a connection only to the writer instance.Expected Behavior
When connecting to a read-only cluster endpoint,
failoverMode
should default toreader-or-writer
. If a failover occurs, the plugin should reconnect to an available reader instance.What plugins are used? What other connection properties were set?
auroraConnectionTracker,failover2,efm2
Current Behavior
I'm connecting to an Aurora RDS cluster via the read-only cluster endpoint using MySQL Connector/J. The JDBC URL is as follows:
jdbc:aws-wrapper:mysql://database-test-name.cluster-ro-XYZ.us-east-2.rds.amazonaws.com:3306/my_database
With finer logging enabled, the wrapper outputs the following log from
FailoverConnectionPlugin.java:248
:During a failover, the following log is generated by
FailoverConnectionPlugin.java:484
:After the failover process, the wrapper connects to the writer instance.
Reproduction Steps
Middleware and library versions:
software.amazon.jdbc:aws-advanced-jdbc-wrapper:2.5.1
com.mysql:mysql-connector-j:8.4.0
Sample code:
Steps to reproduce:
Possible Solution
The
failoverMode=STRICT_WRITER
log appears to originate here:aws-advanced-jdbc-wrapper/wrapper/src/main/java/software/amazon/jdbc/plugin/failover2/FailoverConnectionPlugin.java
Line 248 in b367f4e
It seems that
software.amazon.jdbc.util.RdsUtils#identifyRdsType
is called with theinitialUrl
, but perhaps only the hostname should be passed to this method. This might lead to an incorrectresUrlType
being set:aws-advanced-jdbc-wrapper/wrapper/src/main/java/software/amazon/jdbc/plugin/failover2/FailoverConnectionPlugin.java
Line 236 in b367f4e
Additional Information/Context
No response
The AWS Advanced JDBC Driver version used
2.5.1
JDK version used
Corretto-21
Operating System and version
amazoncorretto:21
docker image on ECS Fargate (x86)The text was updated successfully, but these errors were encountered: