brettwooldridge/HikariCP · error · SQLException

${poolName} - Interrupted during connection acquisition

Error message

${poolName} - Interrupted during connection acquisition

What it means

HikariPool.getConnection() waits on the connection bag with interrupts enabled; if the waiting thread is interrupted it restores the interrupt flag and wraps the InterruptedException in a SQLException tagged with the pool name. This preserves JDBC's checked-exception contract while not swallowing the interrupt.

Source

Thrown at src/main/java/com/zaxxer/hikari/pool/HikariPool.java:188

            else {
               metricsTracker.recordBorrowStats(poolEntry, startTime);
               if (isRequestBoundariesEnabled) {
                  try {
                     poolEntry.connection.beginRequest();
                  } catch (SQLException e) {
                     logger.warn("beginRequest Failed for: {}, ({})", poolEntry.connection, e.getMessage());
                  }
               }
               return poolEntry.createProxyConnection(leakTaskFactory.schedule(poolEntry));
            }
         } while (timeout > 0L);

         metricsTracker.recordBorrowTimeoutStats(startTime);
         throw createTimeoutException(startTime);
      }
      catch (InterruptedException e) {
         Thread.currentThread().interrupt();
         throw new SQLException(poolName + " - Interrupted during connection acquisition", e);
      }
      finally {
         suspendResumeLock.release();
      }
   }

   /**
    * Shutdown the pool, closing all idle connections and aborting or closing
    * active connections.
    *
    * @throws InterruptedException thrown if the thread is interrupted during shutdown
    */
   public synchronized void shutdown() throws InterruptedException
   {
      try {
         poolState = POOL_SHUTDOWN;

         if (addConnectionExecutor == null) { // pool never started

View on GitHub (pinned to a4d93f4f85)

Solutions

  1. Find who interrupts the thread (shutdownNow, Future.cancel(true), thread pools) and avoid interrupting tasks blocked on JDBC
  2. Tune connectionTimeout / maximumPoolSize so acquisition does not block long enough to be interrupted
  3. Catch SQLException and re-check Thread.currentThread().isInterrupted() to honor cancellation
  4. Fix the upstream cause: database slowness or pool exhaustion making threads wait in the first place

Example fix

// before
Future<Connection> f = pool.submit(() -> ds.getConnection());
f.cancel(true); // interrupts thread inside getConnection -> SQLException

// after
// let the task finish or use connectionTimeout to bound waiting:
HikariConfig cfg = new HikariConfig();
cfg.setConnectionTimeout(3000); // bounded wait, no interrupt needed
Defensive patterns

Strategy: try-catch

Try / catch

try { conn = ds.getConnection(); }
catch (SQLException e) {
    if (Thread.currentThread().isInterrupted()) {
        Thread.currentThread().interrupt();
        // honor cancellation: abort this unit of work
    }
    throw e;
}

Prevention

When it happens

Trigger: Thread interrupt during pool shutdown (shutdownExecutor interrupting waiters); application thread timeouts cancelling tasks that are blocked in getConnection (e.g. Future.cancel(true)); connectionPoolTimeout reached while another component interrupts; app server worker thread reclamation.

Common situations: ExecutorService.shutdownNow() while tasks wait for connections under DB outage, request-cancellation frameworks, slow database + aggressive timeouts.

Related errors


AI-assisted analysis of brettwooldridge/HikariCP@a4d93f4f85 (2026-08-14). Data as JSON: /api/errors/c768cebb83ec2537. Report an issue: GitHub.