1

I am troubleshooting an issue with a Spring Boot app connecting to a PostgreSQL database. The app runs normally, but under fairly moderate load it will begin to log errors like this:

java.sql.SQLException: Timeout after 30000ms of waiting for a connection.  

This is running on an Amazon EC2 instance connecting to a PostgreSQL RDS. The app is configured like the following:

spring.datasource.url=jdbc:postgresql://[rds_path]:5432/[db name]
spring.datasource.username=[username]
spring.datasource.password=[password]
spring.datasource.max-active=100

In the AWS console, I see 60 connections active to the database, but that is across several Spring Boot apps (not all this app). When I query the database for current activity using pg_stat_activity, I see all but one or 2 connections in an idle state. It would seem the Spring Boot app is not using all available connections? Or is somehow leaking connections? I'm trying to interpret how pg_stat_activity would show so many idle connections and the app still getting connection pool time outs.

2
  • probably firewall issue. are you sure you opened port for your application server? Commented May 17, 2016 at 23:09
  • Sorry, clarified my post. Only under some load does the application encounter connection errors. Commented May 17, 2016 at 23:30

1 Answer 1

0

Figured it out. Spring is using the Hikari database connection pooling (didn't realize that until after more closely inspecting the stack trace). Hikari configuration parameters have different names, to set the pool size you use maximum-pool-size. Updated that and problem solved.

Sign up to request clarification or add additional context in comments.

2 Comments

Hey Mike! Can you please help me with the setup. I am facing same problem here.
spring.datasource.hikari.maximum-pool-size=1 worked for me

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.