Details
-
Task
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Incomplete
-
3.5.4
-
None
-
Spring Boot Webapp
Description
Hi,
We have the following setup:
- Spring Boot Webapp with MariaDB Driver 3.5.4
- MariaDB 10.5 Replication (one Master, one Replica)
We have configured the following JDBC URL:
jdbc:mariadb:replication://mariadb-primary.domain.net,mariadb-replica.domain.net/my_data_base?characterEncoding=UTF-8&sslMode=trust&enabledSslProtocolSuites=TLSv1.2,TLSv1.3&connectTimeout=2000 |
Our intention is that when the MariaDB Master shuts down or fails, the Spring Boot Webapp should automatically switch to the read-only Replica Server.
The documentation for the driver says that it should automatically switch to the replica when the master fails (failover scenario). However, when we shut down the Master, we are still getting connection errors from the Webapp, which is still trying to connect to the Master instead of the replica.
Caused by: java.sql.SQLNonTransientConnectionException: Socket fail to connect to mariadb-primary.domain.net. Connection refused
|
at org.mariadb.jdbc.client.impl.ConnectionHelper.connectSocket(ConnectionHelper.java:131) |
at org.mariadb.jdbc.client.impl.StandardClient.<init>(StandardClient.java:125) |
at org.mariadb.jdbc.client.impl.MultiPrimaryClient.createClient(MultiPrimaryClient.java:185) |
at org.mariadb.jdbc.client.impl.MultiPrimaryClient.tryConnectToDeniedHost(MultiPrimaryClient.java:144) |
at org.mariadb.jdbc.client.impl.MultiPrimaryClient.connectHost(MultiPrimaryClient.java:109) |
at org.mariadb.jdbc.client.impl.MultiPrimaryClient.<init>(MultiPrimaryClient.java:71) |
at org.mariadb.jdbc.client.impl.MultiPrimaryReplicaClient.<init>(MultiPrimaryReplicaClient.java:51) |
at org.mariadb.jdbc.Driver.connect(Driver.java:87) |
at org.mariadb.jdbc.Driver.connect(Driver.java:104) |
at org.mariadb.jdbc.Driver.connect(Driver.java:29) |
at org.apache.tomcat.jdbc.pool.PooledConnection.connectUsingDriver(PooledConnection.java:346) |
at org.apache.tomcat.jdbc.pool.PooledConnection.connect(PooledConnection.java:227) |
at org.apache.tomcat.jdbc.pool.ConnectionPool.createConnection(ConnectionPool.java:779) |
at org.apache.tomcat.jdbc.pool.ConnectionPool.borrowConnection(ConnectionPool.java:707) |
at org.apache.tomcat.jdbc.pool.ConnectionPool.getConnection(ConnectionPool.java:199) |
at org.apache.tomcat.jdbc.pool.DataSourceProxy.getConnection(DataSourceProxy.java:133) |
at org.springframework.jdbc.datasource.DataSourceUtils.fetchConnection(DataSourceUtils.java:160) |
at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:118) |
at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:81) |
... 82 common frames omitted |
Caused by: java.net.ConnectException: Connection refused
|
at java.base/sun.nio.ch.Net.pollConnect(Native Method)
|
at java.base/sun.nio.ch.Net.pollConnectNow(Unknown Source)
|
at java.base/sun.nio.ch.NioSocketImpl.timedFinishConnect(Unknown Source)
|
at java.base/sun.nio.ch.NioSocketImpl.connect(Unknown Source)
|
at java.base/java.net.SocksSocketImpl.connect(Unknown Source)
|
at java.base/java.net.Socket.connect(Unknown Source)
|
at org.mariadb.jdbc.client.impl.ConnectionHelper.connectSocket(ConnectionHelper.java:118) |
... 100 common frames omitted |
|
What are we missing? do you have some hints?
Best Regards
Nico