[CONJ-1002] Drive reconnect ignores default database/schema setting Created: 2022-08-24  Updated: 2022-09-02  Resolved: 2022-09-02

Status: Closed
Project: MariaDB Connector/J
Component/s: Failover
Affects Version/s: 3.0.6
Fix Version/s: 3.0.8

Type: Bug Priority: Critical
Reporter: Pavel Cibulka Assignee: Diego Dupin
Resolution: Fixed Votes: 0
Labels: None
Environment:

Ubuntu 20.04, Mariadb 10.6.9, Galera Cluster - 3 nodes, Apache Tomcat + Tomcat JDBC Connection Pool, OpenJDK 18.0.2



 Description   

I have following connection settings in tomcat's server.xml:

<Resource auth="Container"
                  name="jdbc/necy-write"
                  username="###"
                  password="###"
                  type="javax.sql.DataSource"
                  driverClassName="org.mariadb.jdbc.Driver"
                  factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
                  jdbcInterceptors="ConnectionState"
                  defaultAutoCommit="false"
                  defaultReadOnly="false"
                  maxActive="50"
                  maxIdle="20"
                  maxWait="1000"
                  initialSize="5"
                  minIdle="2"
                  removeAbandoned="true"
                  rollbackOnReturn="true"
                  testOnBorrow="true"
                  maxAge="300000"
                  useStatementFacade="false"
                  url="jdbc:mariadb:sequential://localhost:###,###:###,###:###"
                  defaultCatalog="necy"
                  connectionProperties="
                    allowMultiQueries=true;
                    rewriteBatchedStatements=true;
                    useAffectedRows=true;
                    useServerPrepStmts=false;
                    useBulkStmts=false;
                  "
                  validationQuery="SELECT 1"
        />

There is default database / schema settings - defaultCatalog="necy". This is sometimes ignored by j/connector.

First I have error (this is as it should be):
java.lang.InterruptedException: Driver has reconnect connection after a communications link failure with address=(host=###)(port=###)(type=primary). In progress transaction was lost

It seems driver somehow reconnects but without setting default database because I have ful log of following errors:

java.util.concurrent.CompletionException: java.lang.InterruptedException: (conn=31) No database selected

I think it is j/connector bug because error message come from MultiPrimaryClient.java file.



 Comments   
Comment by Diego Dupin [ 2022-09-02 ]

There is one possible issue, that occurs on second reconnection when setting database using Connection.setCatalog() (that the case with your configuration).
This will be part of 3.0.8.

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