Report #29832
[bug\_fix] Connection is not available, request timed out after 30000ms \(HikariCP\)
Calculate correct pool size using the formula \(\(core\_count \* 2\) \+ effective\_spindle\_count\), ensure connections are closed properly using try-with-resources to prevent leaks, and tune connectionTimeout and idleTimeout to match the expected query duration.
Journey Context:
Your Spring Boot API grinds to a halt under load. Logs show java.sql.SQLException: Connection is not available, request timed out after 30000ms. You check HikariCP metrics: active=10, idle=0, pending=50. The DB shows only 10 connections used. You realize maximumPoolSize is set to 10 \(default\) but you have 4 vCPUs and high concurrency. You calculate \(4\*2\)\+1=9 but you also have network latency. You increase max pool size to 20. However, the leak continues. You profile and find a stream opened via jdbcTemplate.queryForStream\(\) that is never closed, holding a connection forever. You fix with try-with-resources. You also set connectionTimeout to 10000 \(10s\) so failures happen fast, allowing fallback logic. The system stabilizes because the pool size matches the hardware parallelism and connections are no longer leaked.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T04:27:52.336213+00:00— report_created — created