스프링부트 새벽 첫 요청만 unexpected end of stream이 납니다
조회 3 · 댓글 0
지난번 nginx 뒤에 둔 그 스프링부트 서버입니다. 낮 시간대에는 멀쩡한데 트래픽이 거의 없는 새벽에 첫 요청이 들어오면 간헐적으로 500이 나고, 바로 다시 호출하면 정상입니다. 한 번 실패하고 나면 그 뒤로는 또 멀쩡합니다.
환경은 이렇습니다.
Spring Boot 3.2.4 (spring-boot-starter-data-jpa)
HikariCP 5.1.0 (기본값, 별도 튜닝 안 함)
MariaDB 10.6, JDBC: mariadb-java-client 3.3.x
OpenJDK 17, Ubuntu 22.04실패할 때 애플리케이션 로그입니다.
WARN com.zaxxer.hikari.pool.PoolBase : HikariPool-1 - Failed to validate connection
org.mariadb.jdbc.Connection@3f1a2b (Connection.setNetworkTimeout cannot be called
on a closed connection). Possibly consider using a shorter maxLifetime value.
...
org.springframework.dao.DataAccessResourceFailureException: ...
Caused by: java.sql.SQLNonTransientConnectionException:
(conn=1832) unexpected end of stream, read 0 bytes from 4 (socket was closed by server)
Caused by: java.io.EOFException: unexpected end of stream, read 0 bytes from 4DB 쪽 설정도 확인해봤습니다.
MariaDB [(none)]> SHOW VARIABLES LIKE 'wait_timeout';
+---------------+-------+
| wait_timeout | 600 |
+---------------+-------+HikariCP는 기본값 그대로라 maxLifetime이 1800000(30분)으로 찍혀 있습니다. 지금까지 해본 건 application.yml에 connection-test-query로 SELECT 1을 넣어본 것과, 커넥션 수를 늘려본 정도인데 새벽 첫 요청 실패는 계속 재현됩니다. DB 앞단에 별도 프록시나 LB는 없고 앱에서 바로 붙습니다.
maxLifetime 기본값과 wait_timeout 600을 그대로 둬도 되는 건지, 둘 중 뭘 어느 쪽에 맞춰야 이 증상이 없어지는지 궁금합니다. 혹시 validation만으로는 못 막는 이유가 따로 있나요?
로그인 후 답글을 남길 수 있습니다.