{"record":{"id":"c768cebb83ec2537","repo":"brettwooldridge/HikariCP","slug":"poolname-interrupted-during-connection-acquis","errorCode":null,"errorMessage":"${poolName} - Interrupted during connection acquisition","messagePattern":"(.+?) - Interrupted during connection acquisition","errorType":"exception","errorClass":"SQLException","httpStatus":null,"severity":"error","filePath":"src/main/java/com/zaxxer/hikari/pool/HikariPool.java","lineNumber":188,"sourceCode":"            else {\n               metricsTracker.recordBorrowStats(poolEntry, startTime);\n               if (isRequestBoundariesEnabled) {\n                  try {\n                     poolEntry.connection.beginRequest();\n                  } catch (SQLException e) {\n                     logger.warn(\"beginRequest Failed for: {}, ({})\", poolEntry.connection, e.getMessage());\n                  }\n               }\n               return poolEntry.createProxyConnection(leakTaskFactory.schedule(poolEntry));\n            }\n         } while (timeout > 0L);\n\n         metricsTracker.recordBorrowTimeoutStats(startTime);\n         throw createTimeoutException(startTime);\n      }\n      catch (InterruptedException e) {\n         Thread.currentThread().interrupt();\n         throw new SQLException(poolName + \" - Interrupted during connection acquisition\", e);\n      }\n      finally {\n         suspendResumeLock.release();\n      }\n   }\n\n   /**\n    * Shutdown the pool, closing all idle connections and aborting or closing\n    * active connections.\n    *\n    * @throws InterruptedException thrown if the thread is interrupted during shutdown\n    */\n   public synchronized void shutdown() throws InterruptedException\n   {\n      try {\n         poolState = POOL_SHUTDOWN;\n\n         if (addConnectionExecutor == null) { // pool never started","sourceCodeStart":170,"sourceCodeEnd":206,"githubUrl":"https://github.com/brettwooldridge/HikariCP/blob/a4d93f4f85517f90e632b795486d7102e933d7ff/src/main/java/com/zaxxer/hikari/pool/HikariPool.java#L170-L206","documentation":"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.","triggerScenarios":"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.","commonSituations":"ExecutorService.shutdownNow() while tasks wait for connections under DB outage, request-cancellation frameworks, slow database + aggressive timeouts.","solutions":["Find who interrupts the thread (shutdownNow, Future.cancel(true), thread pools) and avoid interrupting tasks blocked on JDBC","Tune connectionTimeout / maximumPoolSize so acquisition does not block long enough to be interrupted","Catch SQLException and re-check Thread.currentThread().isInterrupted() to honor cancellation","Fix the upstream cause: database slowness or pool exhaustion making threads wait in the first place"],"exampleFix":"// before\nFuture<Connection> f = pool.submit(() -> ds.getConnection());\nf.cancel(true); // interrupts thread inside getConnection -> SQLException\n\n// after\n// let the task finish or use connectionTimeout to bound waiting:\nHikariConfig cfg = new HikariConfig();\ncfg.setConnectionTimeout(3000); // bounded wait, no interrupt needed","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { conn = ds.getConnection(); }\ncatch (SQLException e) {\n    if (Thread.currentThread().isInterrupted()) {\n        Thread.currentThread().interrupt();\n        // honor cancellation: abort this unit of work\n    }\n    throw e;\n}","preventionTips":["Never Future.cancel(true) tasks that may block in getConnection","Bound waiting via connectionTimeout so interrupts are unnecessary","Keep pool capacity adequate to avoid long acquisition waits"],"tags":["hikaricp","concurrency","interruption","connection"],"backgroundTag":null,"analyzedSha":"a4d93f4f85517f90e632b795486d7102e933d7ff","analyzedAt":"2026-08-14T12:11:37.292Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}