The topic has been crammed a lot since ancient times, when mammoths went with spears
There is a script on php that checks the connection to the servers, jerks crown every 5 minutes
When an error sends it to the mail and still sms-koi wakes
<?php ini_set('max_execution_time',10); error_reporting(E_ALL); ini_set("display_errors",1); function logger($obj){echo date('Ymd H:i:s')," ::: ",print_r($obj,TRUE),"\n";} function shutdown(){ if( $a = error_get_last() ) logger($a); else logger(".:: NOERRORS ::."); } register_shutdown_function('shutdown'); function errorConnection($host,$user,$pass,$base) { $error = FALSE; $db = new mysqli($host,$user,$pass,$base); if( $db->connect_errno ) return "[1] ".$db->connect_error; if( !$db->query("SET @tstcon=1") ) $error = "[2] ".$db->error; $db->close(); return $error; } $mysqlUser = 'tstcon'; $mysqlPass = 'tstcon'; $mysqlBase = 'tstcon'; $arrHost = [ ['host'=>'1.site.ru','ip'=>'11.11.11.11'], ['host'=>'2.site.ru','ip'=>'22.22.22.22'], ['host'=>'3.site.ru','ip'=>'33.33.33.33'], ['host'=>'4.site.ru','ip'=>'44.44.44.44'], ]; logger(".:: STARTTEST ::."); $resMsg = ''; $errorExist = FALSE; $errorHostSMS = ''; foreach( $arrHost AS $h ) { $ip = $h['ip']; $host = $h['host']; if( $error = errorConnection($host,$mysqlUser,$mysqlPass,$mysqlBase) ) { $errorExist = TRUE; $_msg = "$host $error [byHOST]"; $resMsg .= "$_msg<br>"; logger("$host $error"); $errorHostSMS .= "\n{$_msg}"; if( $error = errorConnection($ip,$mysqlUser,$mysqlPass,$mysqlBase) ) { $_msg = "$host $error [byIP]"; $resMsg .= "$_msg<br>"; logger("$host $error"); $errorHostSMS .= "\n{$_msg}"; } else { $_msg = "$host GOOD [byIP]"; $resMsg .= "$_msg<br>"; logger("$host $error"); $errorHostSMS .= "\n{$_msg}"; /// Добавим процесс-лист /// Пока костыльно $db = new mysqli($ip,$mysqlUser,$mysqlPass,$mysqlBase); $sql = "SHOW FULL PROCESSLIST;"; $res = $db->query($sql); if( @$res->num_rows ) { $resMsg .= "PROCESS LIST >>><br>"; while( $row = $res->fetch_assoc() ) { $resMsg .= implode(' ::: ',$row)."<br>"; } $resMsg .= "PROCESS LIST <<<<br>"; } } } else { $_msg = "$host доступен"; $resMsg .= "$_msg<br>"; logger("$host доступен"); ///$errorHostSMS .= "\n{$_msg}"; } } if( $errorExist ) { /// ОТправляет на почту и смс }
At first did not pay attention to the night messages, but they began to bother
Suddenly, Google at this moment will go, or else, the client!
The message is something like this:
1.site.ru доступен 2.site.ru доступен 3.site.ru [1] MySQL server has gone away [byHOST] 3.site.ru GOOD [byIP] PROCESS LIST >>> 23235528 ::: tstcon ::: 33.33.33.33:54562 ::: tstcon ::: Query ::: 0 ::: ::: SHOW FULL PROCESSLIST PROCESS LIST <<< 4.site.ru доступен
I read first about "MySQL server has gone away", and maybe I didn’t understand correctly, then this server itself disconnects due to a long query or too large a package ?!
My thoughts:
1. The script twitches every 5 minutes, the message is one, it means one-time, in the process the sheet is clean
2. After connecting to the host, I immediately pull the same code, only the connection is already on IP, a fraction of a second and all the rules; There is a separate script that outside of this query only monitors all sql queries during the day, there is also empty at this time.
3. It remains to assume that the problem is networked; Is that possible?
At night, the server runs the backup script: the bases are dumped, compressed on the fly, then the old ones are cleaned by time, and at the end the fill in the repository
At first I thought that the matter in the dumps and the server is not up to the test connection, but judging by the time, I feel the matter is different
The message arrived at 4:21 Moscow time
In the logs, also in Moscow time:
... не беру во внимание, что было раньше ... 2019/04/26 04:13:09 - Synchronization rclone sync /opt/backups StorageName:3.site.ru 2019/04/26 04:14:11 Unsolicited response received on idle HTTP channel starting with "HTTP/1.0 408 Request Time-out\r\nCache-Control: no-cache\r\nConnection: close\r\nContent-Type: text/html\r\n\r\n<html><body><h1>408 Request Time-out</h1>\nYour browser didn't send a complete request in time.\n</body></html>\n"; err=<nil> 2019/04/26 04:14:11 Unsolicited response received on idle HTTP channel starting with "HTTP/1.0 408 Request Time-out\r\nCache-Control: no-cache\r\nConnection: close\r\nContent-Type: text/html\r\n\r\n<html><body><h1>408 Request Time-out</h1>\nYour browser didn't send a complete request in time.\n</body></html>\n"; err=<nil> 2019/04/26 04:14:11 Unsolicited response received on idle HTTP channel starting with "HTTP/1.0 408 Request Time-out\r\nCache-Control: no-cache\r\nConnection: close\r\nContent-Type: text/html\r\n\r\n<html><body><h1>408 Request Time-out</h1>\nYour browser didn't send a complete request in time.\n</body></html>\n"; err=<nil> 2019/04/26 04:14:11 Unsolicited response received on idle HTTP channel starting with "HTTP/1.0 408 Request Time-out\r\nCache-Control: no-cache\r\nConnection: close\r\nContent-Type: text/html\r\n\r\n<html><body><h1>408 Request Time-out</h1>\nYour browser didn't send a complete request in time.\n</body></html>\n"; err=<nil> 2019/04/26 04:14:11 Unsolicited response received on idle HTTP channel starting with "HTTP/1.0 408 Request Time-out\r\nCache-Control: no-cache\r\nConnection: close\r\nContent-Type: text/html\r\n\r\n<html><body><h1>408 Request Time-out</h1>\nYour browser didn't send a complete request in time.\n</body></html>\n"; err=<nil> 2019/04/26 04:14:11 Unsolicited response received on idle HTTP channel starting with "HTTP/1.0 408 Request Time-out\r\nCache-Control: no-cache\r\nConnection: close\r\nContent-Type: text/html\r\n\r\n<html><body><h1>408 Request Time-out</h1>\nYour browser didn't send a complete request in time.\n</body></html>\n"; err=<nil> 2019/04/26 04:22:06 - ... End of script ...
The hoster, for whom we are renting cloud storage, said these errors, not to pay attention, referring to the Go bug itself, which contains rclone
I am not a networker, but how is it that rclone clogs dns requests and I can’t get rid of it by the host
Maybe this?
All here such "MySQL server has gone away" at night comes at the time of synchronization with external storage
I wrote all this, that would be a complete picture => summarize
In the logs (tail /var/log/mysql/error.log) is empty, I am there first thing, even the config has been rechecked, the log is written there
The first thing that gave Google when searching by mistake:
https://ruhighload.com/mysql+server+has+gone+away+-+kak+pofix
- Connection timeout
- Large or incorrect package
I suppose that all the same first, well, what is the package from me
But still, as it is dull and blurred, I go to the offsite:
https://dev.mysql.com/doc/refman/8.0/en/gone-away.html
The mysql server hasn’t been deleted.
That is, the server itself closed the connection?
Considering my poor network knowledge, there is something strange about SYN-ASK
+ Error "MySQL server has gone away" occurs during a connection, not a request
Then it happens that server1 sent a request to connect to server2
server2 said it was ready, and in response: I’m waiting, waiting for some data from server1
But in view of the possible work of rclone, those errors happened, I don’t know how to correctly say, channel debris in particular DNS, since IP standards are right, and server2 didn’t wait for a connection confirmation from server1
Right guess?
How can this be fixed?