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

org.mariadb.jdbc.internal.util.pool.Pool swallows SQLException during addConnection

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 2.7.2, 2.7.3
    • 2.7.4, 3.0.1-beta
    • pooling
    • None

    Description

      We are using 2.7.2 version of mariadb-connector-j but this issue is also applicable for 2.7.3 version.

      The `org.mariadb.jdbc.internal.util.pool.Pool` has 2 places where it add connections to the pool through a call to (private) method `addConnection()`. Once at that instantiation of the `Pool` here[1] and then regularly through a "-appender" thread here[2].

      The `addConnection()` is expected to throw an `SQLException` when things go wrong it can't add a connection. This exception typically contains crucial information on why a certain connection didn't make it to the pool which can then help analyze why clients calling on this `Pool` instance aren't able to get a `Connection` instance. The constructor of the `Pool` class, rightly logs any `SQLException` it receives from `addConnection()`. However, the thread which regularly "appends" new connections, just "eats" any `SQLException` thrown from `addConnection()` as seen at [2]. As a result, at runtime when for whatever reason if adding connection(s) keeps failing, then any potential `SQLException` that is causing the connection to be added to the pool, is never logged.

      We seem to have hit that state right now in one of our setups. Our `Pool` instance isn't able to hand out any connection to the clients and they keep failing with side-effect errors like:

      ```
      Caused by: java.sql.SQLSyntaxErrorException: No connection available within the specified time (option 'connectTimeout': 30,000 ms)
      at org.mariadb.jdbc.internal.util.exceptions.ExceptionFactory.createException(ExceptionFactory.java:62)
      at org.mariadb.jdbc.internal.util.exceptions.ExceptionFactory.create(ExceptionFactory.java:153)
      at org.mariadb.jdbc.MariaDbPoolDataSource.getConnection(MariaDbPoolDataSource.java:239)
      at com.cfx.db.ConnectionFactory.getConnection(ConnectionFactory.java:52)
      ... 43 common frames omitted
      Caused by: java.sql.SQLSyntaxErrorException: No connection available within the specified time (option 'connectTimeout': 30,000 ms)
      at org.mariadb.jdbc.internal.util.exceptions.ExceptionFactory.createException(ExceptionFactory.java:62)
      at org.mariadb.jdbc.internal.util.exceptions.ExceptionFactory.create(ExceptionFactory.java:171)
      at org.mariadb.jdbc.internal.util.pool.Pool.getConnection(Pool.java:413)
      at org.mariadb.jdbc.MariaDbPoolDataSource.getConnection(MariaDbPoolDataSource.java:237)
      ... 44 common frames omitted

      ```

      whereas the pool is never able to add new connections.

      Would it be possible to change that catch block to log a message similar to what's done in the constructor so that crucial failure information during connection creation is logged and available for later debugging?

      [1] https://github.com/mariadb-corporation/mariadb-connector-j/blob/2.7.2/src/main/java/org/mariadb/jdbc/internal/util/pool/Pool.java#L123
      [2] https://github.com/mariadb-corporation/mariadb-connector-j/blob/2.7.2/src/main/java/org/mariadb/jdbc/internal/util/pool/Pool.java#L140

      Attachments

        Activity

          jaikiran Jaikiran Pai added a comment -

          I've raised a pull request https://github.com/mariadb-corporation/mariadb-connector-j/pull/172 with a potential fix for this issue.

          jaikiran Jaikiran Pai added a comment - I've raised a pull request https://github.com/mariadb-corporation/mariadb-connector-j/pull/172 with a potential fix for this issue.
          jaikiran Jaikiran Pai added a comment -

          Hello Diego,

          Would it be possible to review this issue and the linked PR to see if it can be merged? We plan to have an upgrade of our product in a month and if this change gets implemented and a version of the driver released, then it will help us debug some of the frequent connection issues that we are having on one of our setups.

          jaikiran Jaikiran Pai added a comment - Hello Diego, Would it be possible to review this issue and the linked PR to see if it can be merged? We plan to have an upgrade of our product in a month and if this change gets implemented and a version of the driver released, then it will help us debug some of the frequent connection issues that we are having on one of our setups.
          diego dupin Diego Dupin added a comment -

          Hi jaikiran those information will be thrown at pool creation, but when pool is running.
          The PR is merged, to be release in next 2.7 correction

          diego dupin Diego Dupin added a comment - Hi jaikiran those information will be thrown at pool creation, but when pool is running. The PR is merged, to be release in next 2.7 correction
          jaikiran Jaikiran Pai added a comment -

          Hello Diego, thank you very much for reviewing and merging the PR. This will help us debug some of the issues we have been running into recently (hard to reproduce on a local setup).

          jaikiran Jaikiran Pai added a comment - Hello Diego, thank you very much for reviewing and merging the PR. This will help us debug some of the issues we have been running into recently (hard to reproduce on a local setup).

          People

            diego dupin Diego Dupin
            jaikiran Jaikiran Pai
            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.