We are using PgBouncer as the middle ware for connection pooling for our spring-based application. Within the application, we are using HikariCP for application-level connection pooling.
We have set maxLifeTime
value equal to one hour for HikariCP and idleTimeOut
is set to 30 seconds.
I have observed that we are getting this error when app get a request after a long idle time:
Caused by: org.postgresql.util.PSQLException: Connection attempt timed out. at
org.postgresql.Driver$ConnectThread.getResult(Driver.java:376) at
org.postgresql.Driver.connect(Driver.java:288) at
java.sql.DriverManager.getConnection(DriverManager.java:664) at
java.sql.DriverManager.getConnection(DriverManager.java:247) at
org.postgresql.ds.common.BaseDataSource.getConnection(BaseDataSource.java:88) at
org.postgresql.ds.common.BaseDataSource.getConnection(BaseDataSource.java:71) at
com.zaxxer.hikari.pool.HikariPool.addConnection(HikariPool.java:398) at
com.zaxxer.hikari.pool.HikariPool.lambda$addBagItem$2(HikariPool.java:309) at
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…