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

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.7.2, 2.7.3
    • Fix Version/s: 2.7.4, 3.0.1-beta
    • Component/s: pooling
    • Labels:
      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

            People

            Assignee:
            diego dupin Diego Dupin
            Reporter:
            jaikiran Jaikiran Pai
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Git Integration