결론
DB 커넥션 값과 Spring hikari 의 커넥션 유지 설정값이 맞지 않아서 발생하는 문제.
Spring 세팅 값을 db값 보다 1~2초 빠르게 설정해서 해결.
SHOW variables LIKE '%time%'
DB | HikariCP |
wait_timeout | max-lifetime |
connect_timeout | connection-timeout |
- max-lifetime : 커넨션의 최대 유지 시간 설정. 사용중인 커넥션은 maxLifetime에 상관없이 제거되지않고, 사용중이지 않을 때만 제거된다. 0으로 설정하면 무한 lifetime이 적용되지만, idle-timeout 설정되어 있는 경우에는 적용되지 않는다. (default: 1800000 (30분))
- connection-timeout : pool에서 커넥션을 얻어오기전까지 기다리는 최대 시간. 허용가능한 시간을 초과하면 SQLException이 발생하며, 설정가능한 가장 작은 시간은 250ms 이다. (default: 30000 (30초))
db값이라고 했을때
connect_timeout 10
wait_timeout 300
밀리세컨드이므로 아래와 같이 설정 후 해결.
spring.datasource.hikari.connection-timeout=8000
spring.datasource.hikari.max-lifetime=298000
'JAVA > Spring' 카테고리의 다른 글
카프카 명령어 모음. (0) | 2022.05.29 |
---|