Uploaded image for project: 'MariaDB Connector/J'
  1. MariaDB Connector/J
  2. CONJ-1181

Using MariaDb Connector with MySQL 8.0 with specific Multintenancy Strategy

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Critical
    • Resolution: Fixed
    • 3.3.3, 3.4.0
    • 3.4.1
    • Other
    • None

    Description

      We have a SpringBoot/SpringData application with Hibernate/JPA.

      The application is "multi-tenant" and we are extending Hibernate's AbstractDataSourceBasedMultiTenantConnectionProviderImpl with corresponding TenantIdentifierResolver.

      When a connection is requested we execute "USE

      {schema}

      ".

      While testing, we discovered that requests that are meant for Tenant A were returning data for Tenant B. After much of hair pulling, we discovered that culprit seemed to have been "cachePrepStmts=true" included in connectionURL.

      While it seems that removing this parameter from the URL defaults it to 'false' - our solution. looking at the code, it becomes obvious why we were failing.

      https://github.com/mariadb-corporation/mariadb-connector-j/blob/0db5648c1b90303937b12929b592b8af96498bea/src/main/java/org/mariadb/jdbc/ServerPreparedStatement.java#L72-L75

      It seems rather presumptious to cache results of the queries at the client-side.
      We have Hibernate's session-level cache for that purpose.

      At the very least current schema, should be taken into account.

      We seem to be fine now with this option turned off.

      Attachments

        Activity

          People

            diego dupin Diego Dupin
            mshnayderman Mikhail Shnayderman
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.