[CONJ-551] Provide a way to ignore the load balancing in AWS Aurora while retaining failover Created: 2017-11-27  Updated: 2019-12-19  Resolved: 2017-11-30

Status: Closed
Project: MariaDB Connector/J
Component/s: configuration
Affects Version/s: None
Fix Version/s: N/A

Type: Task Priority: Minor
Reporter: Jacques-Etienne Beaudet Assignee: Diego Dupin
Resolution: Not a Bug Votes: 0
Labels: None

Issue Links:
Relates
relates to CONJ-751 Support Aurora mode with a Master onl... Closed

 Description   

When using AWS Aurora with a read replica and the load balancing provided by the driver, you're faced with potential inconsistency because of the replica lag (an insert is not instantly reflected on the read replicas). This means that you can insert an object, immediately retrieve it on a readOnly=true connection and get null.

I understand that in some cases this lag is acceptable and the load balancing advantages outweigh the consistency. However, there should be an option so that all queries, regarless of the status of the readOnly flag, are routed to the master instance while retaining the failover capabilities of the driver.



 Comments   
Comment by Diego Dupin [ 2017-11-27 ]

There is a solution : Use "failover" connection string : (not "aurora")
jdbc:mariadb:failover://<aurora-cluster-rw-endpoint>/db

When a failover occurs, that solution relies on AWS internal DNS to change to the newly elected master, but on automatic reconnection some operations will be transparently re-executed, like if the failed query was using readOnly, some not: an INSERT query that was in progress - driver cannot know if the command was successfully received by server or not.
(That will avoid creating a useless socket to replicas then. )
The only disadvantage, is that rely on the aurora internal DNS, connection will take a few more seconds compared to using "aurora" in connection string, but that's still a great solution.

Comment by Jacques-Etienne Beaudet [ 2017-11-27 ]

Thanks for answering! This is documentation worth IMO as I'm sure the question will pop again.

Should I keep the finite lifetime of connections in my connection pool (as mentioned in the aurora section) or can I use the default infinite lifetime of the tomcat connection pool with the "failover" mode?

Comment by Diego Dupin [ 2017-11-28 ]

It's better to keep a max lifetime.

Technically that will work: tomcat pool will validate the connection each time it will be used, but if connection has been closed by server (after the time corresponding to @@wait_timeout variable), this validation will have to reach some timeout before automatic reconnection.

It's better to close connection silently after a time than to hang just when a connection is needed.

Comment by Jacques-Etienne Beaudet [ 2017-11-28 ]

Good I'll keep this setting on then.

Once again thanks for your help, I'll close this issue and hopefully it'll come up in google if someone else search for it

Comment by Jacques-Etienne Beaudet [ 2017-11-28 ]

Turns out I can't close my own issues so I'll let you reject it!

Comment by Diego Dupin [ 2017-11-30 ]

ok thanks, I'm closing issue then

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