We have a multi-tenant DataSource implementation, which wraps HikariCP pools and calls setCatalog on connect, like so:
What I'm seeing is sporadic SQL errors indicating a connection is using the default database (from the url) and not the one specified in setCatalog. In debugging, I see that the connection with the error is different than the one created, leading me to think it's an issue with secondary protocol. This seems to happen with Spring MVC controller methods marked as @Transactional(readOnly=true).
I found in reading the source a questionable condition which potentially might be leading to this issue, in MastersSlavesListener:: lockAndSwitchSecondary(): https://github.com/mariadb-corporation/mariadb-connector-j/blob/master/src/main/java/org/mariadb/jdbc/internal/failover/impl/MastersSlavesListener.java#L648
I am thinking that line should rather be " if (currentProtocol != null) ", so that the syncConnection() call can properly copy the database into the newSecondaryProtocol?