I'm getting this exception in production. Things are quiet for weeks at a time and then we get a "rash" of them all of a sudden:
Caused by: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is java.sql.SQLTransientConnectionException: HikariPool-1 - Connection is not available, request timed out after 1031ms.
STEPS TAKEN TO INVESTIGATE THE PROBLEM:
This symptom has well-known possible causes, which I have checked:
JdbcTemplate
is being used correctly, checked: Spring jdbctemplate is it required to close the connection- Using try-with-resource to ensure Connections are closed, checked: Hikari Pool Connection is not available Error
- Database server can support the load, checked (server not busy at all, checked
top
andpg_activity
andnetstat
-- really not much is going on): Hikari connection pool, Connection is not available
What else could be causing this?
Configuration
<bean id="listingDataSource" class="com.zaxxer.hikari.HikariDataSource">
<property name="driverClassName" value="org.postgresql.Driver" />
<property name="jdbcUrl" value="myserver:5432/mydata?reWriteBatchedInserts=true" />
<property name="username" value="${username}" />
<property name="password" value="${password}" />
<property name="minimumIdle" value="1" />
<property name="maximumPoolSize" value="${10}" />
<property name="connectionTimeout" value="1000" />
<property name="leakDetectionThreshold" value="60000" />
<property name="idleTimeout" value="120000" />
<property name="maxLifetime" value="300000" />
</bean>