Report #66292
[bug\_fix] Connection pool exhaustion \(HikariCP/PostgreSQL\)
Segregate long-running operations into a dedicated connection pool with appropriate sizing and longer timeouts, enable \`leakDetectionThreshold\` in HikariCP \(or equivalent\) to identify code holding connections too long, and ensure aggressive transaction commit/close in application code for interactive workloads.
Journey Context:
Your Java Spring Boot 3 application using HikariCP and PostgreSQL starts hanging under moderate load; threads block indefinitely. Thread dumps show \`java.lang.Thread.State: TIMED\_WAITING\` at \`com.zaxxer.hikari.pool.HikariPool.getConnection\(\)\`. The database shows only 10 active connections \(matching \`maximumPoolSize\`\), but all are \`idle in transaction\` for 5\+ minutes. You find a nightly batch job that opens a transaction, fetches 1M rows, processes them in Java, then commits. It holds a connection the entire time. Since the pool is shared between web requests and batch jobs, web requests starve. You configure a second \`DataSource\` bean named \`batchDataSource\` with a dedicated pool \(size 5, high \`connectionTimeout\`\), pointing to the same DB but using a different Hikari pool. You move the batch job to use this pool. For the web pool, you enable \`leakDetectionThreshold=60000\` \(60s\), which logs warnings when connections are held longer than expected, helping catch future leaks. The application recovers because long-running operations no longer monopolize the interactive connection pool.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T17:44:48.563366+00:00— report_created — created