This is a read-only copy of the MariaDB Knowledgebase generated on 2024-11-16. For the latest, interactive version please visit https://mariadb.com/kb/.

MariaDB Connector/J

Hi,

We are using MariaDB Connector/J against our production AWS Aurora RDS and noticed that default socketTimeout is set to 10 seconds against Aurora. Is there a reason behind this default value? Is there any implication of increasing timeout that I should be aware?

We do have transaction layer that times out at 60 seconds. So was thinking to up it to match our higher layer timeout.

any advice is greatly appreciated.

Answer Answered by Diego Dupin in this comment.

Good question !

The value of the timeout socket option does not have to be related to the max time of a transaction.

The connector connects to the database with a socket. The socketTimeout option defined the Socket.setSoTimeout value. A read on that socket that take more time than this value will result as an exception, and kill the socket. This is an error that will be catched by the failover implementation.

Since aurora is design by default to be use as master / slave, socketTimeout has been set to 10s by default to permit failover. 10 seconds is already a lot, and to have an efficient failover, it is necessary that this value be as low as possible.

To be effective, the failover implementation need to detect the problem quickly. If not, new problem will arise : Assuming you are using a connection pool, it implies that the affected connections will not be released until the value of socketTimout . The appplication will not stop during that time, so the connection pool will create many new connections to meet the demands . This will cause a significant increase in resources used in your server and depending of the kind of problem possibly affect the database server. That may cause a lot more problems.

Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.