Mysql – Random “Lost connection to MySQL server at ‘reading initial communication packet’, system error: 0”

MySQLnetworking

Sometimes I get the error from MYSQL server:

Lost connection to MySQL server at 'reading initial communication packet', system error: 0 

I cannot find the cause, since most of the time it works, but every week for some hours I get this error. I googled, but there seem to be only users which have this error permanently. But in this case, it only occurs sometimes. I checked hosts.allow and hosts.deny, but the host is allowed and not denied.

Also sometimes I get the error:

File './database/table.MYD' not found (Errcode: 24) 

It occurs very rarely. But it occurs for some hours once a week, sometimes on multiple days, but suddenly the problem disappears again. I have checked the open files limit. It's 2048 and should be absolutely enough. I also tried to increase the number of open files nevertheless, but no effect. I thought, perhaps the process does not close some tables. But this is impossible, because after a while everythings o.k. again and the process opens maximum 100 tables at once. I also checked the MySQL-runtime-environment, and there were 930 opened files. I cannot explain that. After a while it's 129.

I am running a MySQL-Server on a SUSE-Linux machine. I connect to the MySQL-Server from another host by the command line tool "mysql" and by MySQL-C-connector. The MySQL-Server is version 5.0.67.

Best Answer

The problem is solved now.

It turned out that our backup program "mysqlhotcopy" was the problem.

The cause is that mysqlhotcopy locks, as I can see it, in one statement all tables of all databases when called without database parameter, respectively all tables of one database when called with database parameter. As our databases can contain some thousands of tables, this turned out to be impossible with our current system configuration.

So I wrote a new mysqlhotcopy-script and the problem has disappeared up to now.