D
D
Dmitry Zubkov2015-06-01 19:31:18
PHP
Dmitry Zubkov, 2015-06-01 19:31:18

How to debug SQLSTATE[HY000]: General error: 2006 Mysql server has gone away?

Good day!
After the implementation of several large mailings (~ 1 million letters in each), the hands got around to "combine" the project and debug errors that have been an eyesore for a long time. There are about 500 errors in the logs daily:

SQLSTATE[HY000]: General error: 2006 Mysql server has gone away

All errors occur only during large mailings. That is, errors appear only in cases when we try to make requests of the same type in several threads to fetch data into the mailing template. Requests are the easiest. The requests themselves, for which an error is returned, are logged - after the fact, after the mailing, they are executed in thousandths of a second. In different mailing lists, requests are different, but always easy. At the same time, during the mailing, the load on mysql is imperceptible - we repeatedly checked and rechecked all the zabbix indicators to bloody tears - by all criteria, the server with mysql on board feels great during the mailing, no anomalies and bursts are observed on any of the graphs. In the course of the day, during traffic peaks, the load is many times higher than during the mailing, but such errors do not occur. Admin confirms
Actually, at the moment there is still no idea about the causes of the error. There is a goal to understand its nature. Google did not save, although there are enough similar topics, in most cases the standard advice is to increase the values ​​​​of the max_allowed_packet and wait_timeout variables. I checked the values ​​- on the master and on the slaves, these parameters have very large values.
Oh yes, another point that is probably important in this case - all errors are poured out in one particular second, although the mailing itself lasts about 30 minutes. That is, for example, the mailing can work for 20 minutes, then 100 errors fall into the log immediately within a second and then she peacefully continues to work. At the same time, everything is smooth on the zabbix charts.
I would like to understand if it is possible to get more information about this error - to find out which scenario is causing it to occur?
PDO contacted mysql but didn't get a response? If so, how did he determine that no response had been received? Fell off on some of the timeouts? On connection or wait_timeout?
Is it possible to do some sort of detailed profiling in case an error occurs?
I would be grateful for answers if someone has already encountered a similar problem. If I forgot to mention some important nuances - I will add, ask questions, I will gladly share information.
PS It's probably not worth discussing changing the mailing logic at the moment (there is such an idea, but now the goal is to learn to understand the nature of the error).

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2016-11-11
@kascor

I was saved by increasing wait_timeout from 10 to 60

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question