4,438,175 th visitor since 2017.2.1 ( Today : 4689 )
Programming
No. 804
Name. swindler
Subject. mysql Got timeout reading communication packets
Main Cate. Java
Sub Cate.
Date. 2018-06-29 10:25
Hit. 6010 (59.29.233.1)
File.
해결을 포기하고, 꼼수로 처리하기는 진짜 오랜만인것 같다.

일단 java 프로그램에서 다음과 같은 에러가 발생함.

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

The last packet successfully received from the server was 105,854 milliseconds ago. The last packet sent successfully to the server was 0 milliseconds ago.
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

The last packet successfully received from the server was 105,854 milliseconds ago. The last packet sent successfully to the server was 0 milliseconds ago.


-------------------
java.sql.SQLException: Operation not allowed after ResultSet closed


--------------------
mysql DB에는 다음과 같은 로그가 생김.
2018-06-29T01:19:53.534608Z 14 [Note] Aborted connection 14 to db: 'lab' user: 'root' host: '127.0.0.1' (Got timeout reading communication packets)




프로그램이 대충 다음과 같이 돌아감.

while(ReseultSet.next()) {
// 여기서 DB와 상관없이 시간이 오래걸리는 작업이 있음.
}

작업하는 사이에 timeout에 걸려서 접속이 끊긴 것으로 추정됨.

db에 있는 각종 timeout 시간을 늘려도 해결이 안됨.

Java코드에서 pstmt.setQueryTimeout(180);
이런식으로 해도 해결이 안됨....


그래서, while 안에서 적당히 쿼리를 한번씩 던져줘서 꼼수로 해결할려고 했는데,
그렇게 수정하자니 소스가 말도 안 되는 수준이 될것 같은 문제가 발생...


잠시 생각좀 해보고 결정해야겠음 ㅠㅠ

-> 일단 connector/J string에 다음과 같이 autoReconnect를 넣어서 처리함

autoReconnect=true




[바로가기 링크] : http://coolx.net/cboard/develop/804



swindler 새로운 문제가 있음. 지금 character set 관련문제가 있어서 처음접속시에 SET names를 던지는데, reconnect 될때 적용되지 않는 문제가 있ㅇ므. 2018-07-01
swindler 결국 autoreConnect 할때 SET NAMES 적용되지 않는 문제때문에 더 찾아보다가, wait_timeout이 제대로 설정되지 않음을 발견. wait_timeout을 늘리면 해결됨 2018-07-24
swindler SET GLOBAL wait_timeout=1800; 2019-08-29
Name
Password
Comment
Copyright © 1999-2017, swindler. All rights reserved. 367,611 visitor ( 1999.1.8-2004.5.26 ), 2,405,771 ( -2017.01.31)

  2HLAB   2HLAB_Blog   RedToolBox   Omil   Omil_Blog