I have a Spring Boot 1.5 application with Spring Batch 3.0.7 and Java 8. I recently received some connection timeouts when a scheduled job tried to start with 5 threads, while another long-running batch job was running. It appears there is contention for the connections by the combined 15 threads. I haven't found any documentation, blogs or questions that seem to address the correlation with threads and pools in Spring Batch.
I have 3 connections using HikariCP, each datasource configured as default (10 connections):
- batcdb (postgres)
- readdb (oracle)
- writedb (postgres)
I have 2 jobs:
- Job 1 (long-running) - max-pool-size: 10
- Job 2 (short-running) - max-pool-size: 5
I have been able to recreate this error numerous times.
I wanted to try something different, so I upped my AWS EC2 instance type to a C4.xlarge, and set max-pool-size: 20. This is where things get really confusing, instead of the HikariCP pools showing 20 connections active, it consistently stays at 10 connections active, 10 connections idle. Which tells me there may be a different setting around the number 10 somewhere?
DEBUG 3054 --- [cdb housekeeper] com.zaxxer.hikari.pool.HikariPool : writedb - Pool stats (total=20, active=10, idle=10, waiting=0)
Note: I have also observed the chunk logging output ~20 threads in the logs, which would tell me that the threading/taskExecutor is behaving as intended.
[taskExecutor-1]
...
[taskExecutor-20]
I would prefer not to keep throwing more connections at my application to allow concurrent jobs to run. Any suggestions and ideas will be greatly appreciated.
throttle-limit: 10, which seems to be the reason for what I had expected to be a continued correlation between threads and connections. With throttle-limit increased to 20, all 20 connections are showing as active. - shawnjohnson