I am using Spring Boot application to connect to remote Postgresql server (9.2) running behind Azure Network Security Group.
When I set the hikari properties to default (means maxLifetime as 30 mts),I frequently got Connection Unavailable exception. On research I found that, the connection closed by the Server is still maintained in the pool because of its lifetime and so to resolve the issue, I reduced the lifetime of Connection object to 5 minutes with a Pool size of 2.Following are the hikari properties I set:
spring.datasource2.hikari.max-lifetime=300000
spring.datasource2.hikari.maximumPoolSize=2
logging.level.com.zaxxer.hikari=TRACE
logging.level.com.zaxxer.hikari.HikariConfig=DEBUG
I have restriction of only 20 allowed connections from Postgres and it is not managed by me I have access restrictions. As hikari is creating new two objects every 5 minutes by closing the connection in my Spring Boot application, I see that too many connections are bombarded in the Postgres server by using the pg_stat_activity query and I get Too many connections for the user.
I tried increasing the maxLifeTime of connection object to 10, 15 and 20 minutes in successive tries but still I could see more connections from DB server side
The connections closed by Hikari is not closed in the Postgres Server. What is the default value/time that a connection is kept alive or idle in the Postgres server? How can I resolve this issue?
Or is there a way to close the connection on Postgresql server through Hikari?
I wanted to maintain pool size of 2 as I have only 20 allowed total connections
Thank you in advance!