Closed firateren52 closed 1 month ago
Hi @firateren52 ,
Thanks for reaching out and raising this issue.
Would you give more details about the application:
We'll take a look at this and keep you updated as we investigate. Thank you for your patience!
Hi,
A quick question about your connection url. I don't see configuration parameter enableGreenNodeReplacement
in there. I'd expect to see something ...&enableGreenNodeReplacement=true
in the connection url.
Hi @sergiyvamz, sorry i pasted from a wrong place so please disregard that, can you please remove your quote from your comment as it shows our database url? i shared more redacted logs, sample code to show how we configure HikariCP and also added the DataSourceConnectionProvider
code we updated to add 2 log statements which you can see in logs. If you compare the properties listed in "Trying to connect to reader" log with the properties listed in "openConnection failed props" logs it's pretty obvious enableGreenNodeReplacement was present but then it's removed. I did write a simple unit test and verified this behavior as well and pointed out the line where enableGreenNodeReplacement
is being removed in the Possible Solution section. Le me know if you need more info please. Thanks.
Hi @firateren52, we merged a fix for this issue, could you please check out the snapshot build aws-advanced-jdbc-wrapper-2.3.8-20240719.225239-21.jar and let us know if this resolves the issue for you? For details on how to use the snapshot build see here.
@karenc-bq yes i verified with the snapshoot the bug is fixed. When will you release the next version? is it recommended to use this snapshoot version in prod? thank you!
Thanks @firateren52 for confirming the fix with our snapshot build. We are preparing for a new release and it will come out before the end of July.
Describe the bug
We are using this driver together with MySQL driver to connect to an AWS Aurora MySQL 8.0 cluster using default plugins with an internal HikariCP connection pool. We have the incorrect SERVER_ID bug which has
-green-xxx
after B/G switchover. When we have long running queries more than 5 minutes queries were failing, we found out our problem was similiar to https://github.com/aws/aws-advanced-jdbc-wrapper/issues/678. We started to use enableGreenNodeReplacement=true flag as it was supposed to fix but it didn't fix our problem. After some debugging i think enableGreenNodeReplacement implementation has a bug. When we disable efm2 plugin then our queries were succeeding.Expected Behavior
We expect that enableGreenNodeReplacement=true flag actually works for Aurora MySQL database. We use efm2 plugin to use hostnames for the reader replicas that can actually be resolved( remove
-green-xxx
), so that the internal connection pools for read-only connections are populated.What plugins are used? What other connection properties were set?
Plugins: auroraConnectionTracker,failover,efm2
Current Behavior
The driver seems to use data from the @@aurora_server_id to generate fqdn to connect to, but since the instances seem to retain server-ids from the blue/green deployment the fqdn is not valid and it fails to connect. enableGreenNodeReplacement flag is being removed for property list.
Reproduction Steps
Connect to an AWS Aurora MySQL cluster that has been deployed with blue/green deployment and therefore has incorrect
SERVER_ID
ininformation_schema.replica_host_status
table and at least one reader replica using the plugins above. Aurora MySQL cluster version should be lower than 3.07.0 as this SERVER_ID bug has been fixed in this version.more info: https://docs.aws.amazon.com/AmazonRDS/latest/AuroraMySQLReleaseNotes/AuroraMySQL.Updates.3070.html
Possible Solution
After some debugging i think i found the issue, in MysqlConnectorJDriverHelper class you are removing properties except a provided list and therefore enableGreenNodeReplacement flag is being removed too so when you check the flag in DataSourceConnectionProvider the flag isn't there and exception is thrown. So for Aurora MySQL databases enableGreenNodeReplacement flag is ineffective, other databases may have this bug as well.
https://github.com/Bit-Quill/aws-advanced-jdbc-wrapper/blob/5f22be871112e10051881a404f531da057373c1d/wrapper/src/main/java/software/amazon/jdbc/targetdriverdialect/MysqlConnectorJDriverHelper.java#L67
https://github.com/aws/aws-advanced-jdbc-wrapper/blob/e90e1aba7e34bb1068789469cd508c35a5cd7b17/wrapper/src/main/java/software/amazon/jdbc/DataSourceConnectionProvider.java#L177
Additional Information/Context
We have reproduced this bug in both below Aurora RDS MySQL versions:
Aurora DB instances:
SERVER_ID values after B/G switchover:
Other libraries: HikariCP version 5.0.1 Dagger version 2.9
HikariCP normal connection params:
HikariCP reader connection params:
sample code to show how we create connections:
software.amazon.jdbc.DataSourceConnectionProvider update we did to log properties and other info:
The AWS Advanced JDBC Driver version used
4.3.7
JDK version used
openjdk 11.0.19 2023-04-18 LTS
Operating System and version
Linux 6.1.94-99.176.amzn2023.x86_64 x86_64