[CONJ-759] Connections sometimes don't respect setCatalog Created: 2020-02-03 Updated: 2020-03-06 Resolved: 2020-03-06 |
|
| Status: | Closed |
| Project: | MariaDB Connector/J |
| Component/s: | aurora, Failover |
| Affects Version/s: | 2.4.4, 2.5.4 |
| Fix Version/s: | 2.6.0 |
| Type: | Bug | Priority: | Major |
| Reporter: | Jared Stehler | Assignee: | Diego Dupin |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Environment: |
AWS Aurora RDS with 1 replica |
||
| Description |
|
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? |
| Comments |
| Comment by Jared Stehler [ 2020-02-03 ] | |||||||||||||||
|
Further, I see similar logic in lockAndSwitchMaster(), but with the != condition:
| |||||||||||||||
| Comment by Diego Dupin [ 2020-03-06 ] | |||||||||||||||
|
done by this PR from reporter (jared stehler) |