[컴] HikariCP의 maxLifeTime 과 MySQL의 wait_timeout

wait_timeout 확인법 / 설정 방법 / 히카리 / hikari cp / connection pool 과 연동 / 어떻게 연동

HikariCP의 maxLifeTime 과 MySQL의 wait_timeout

MySql 의 wait_timeout 과 interactive_timeout

  • https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_wait_timeout

thread 가 시작할때, session 의 wait_timeout 값은 global wait_timeout 값으로 초기화 된다. 또는 global interactive_timeout 값으로 초기화 된다. client 가 interactive client 이면, interactive_timeout 을 사용하고, 그렇지 않으면 wait_timeout 을 사용한다.

  • interactive_timeout : https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_interactive_timeout

서버가 interactive connection 에서 close 하지 않고 activity 를 기다리는 시간이다.(second 로 표현된다.) CLIENT_INTERACTIVE option 을 사용하는 client 가 interactive client 이다. (즉, mysql_real_connect() 를 사용해서 접속할때 CLIENT_INTERACTIVE 옵션을 사용하면 된다.)

  • wait_timeout : https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_wait_timeout

서버가 noninteractive connection 에서 close 하지 않고 activity 를 기다리는 시간이다.(second 로 표현된다, 기본값은 28800s 이다.)

다음 query 를 통해 확인할 수 있다.

SHOW variables like "%_timeout%";
SHOW global VARIABLES LIKE '%_timeout%';

wait_timeout 값 설정 요령

See Also

  1. HikariCP issue, #863, Keeping Connection Open in MySql Transactions
    • sql 을 수행하지 않고, wait_timeout 보다 connection 을 오래 잡아두면 transaction 중간에 connection 을 lost 할 수 있다.
    • deadlocks/lock timeouts
  2. Lost connection to MySQL server during query : Forums : PythonAnywhere

댓글 없음:

댓글 쓰기