Bug #10525 Under heavy load connection through Unix socket are failing
Submitted: 10 May 2005 20:55 Modified: 11 Jul 2006 12:08
Reporter: NOT_FOUND NOT_FOUND Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server Severity:S2 (Serious)
Version:4.0.24 OS:Linux (fedora core 3)
Assigned to: Geert Vanderkelen CPU Architecture:Any

[10 May 2005 20:55] NOT_FOUND NOT_FOUND
Description:
Hello,
The issue is only appearing under heavy load (50-100 coucurent connections), in this specific case the issue occurs using PHP 4.3.10 and the following error message appears the apache error log (Apache/2.0.52 (Fedora) ) for each failed connections :
 PHP Warning: mysql_connect(): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (11)
There is no error in the mysql log file.

After some investigation I noticed that this issue is already present on mysql 3.23.x versions... always for fedora core 3 (might be some other OS).

The connection are not all failing but the more concurent hit there is the more connections failure occurs. This can happen with lots of free memory (> 250 Mo). The server in used also runs apache and php, the cpu usage is at the maximum when the issue occurs us 70-80 % sys 30-20 %

A work arround is to use the tcp socket (using 127.0.0.1 instead of localhsot when connecting to mysql through php) doing that 250 coucurent can connect during a stress testing of 2 hours without any connection issue.

The open-files-limit is set to 36436  in my.cnf and also in the system.

How to repeat:
Running a stress testing for exemple with apache benchmark (Version 2.0.41-dev) : ab -c100 -n 3000 "http://localhost/testpage.php" will generate some connection failure : Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (11)
The connection need to be done through Unix socket using tcp socket works fine.

The amount of concurent users to reproduce the issue may change depending of the server capabilities. (50 to 100 are enough for PIV 2.66 with 512 Mo using Fedora core 3) 

Suggested fix:
Work arround is to use the tcp socket by entering the ip adress or the hostname of the server instead of localhost.
[4 Aug 2005 14:40] NOT_FOUND NOT_FOUND
Hello,
good to see that this bug is under investigation. If you need some more information or some more test results please let me know.
The new version of the distribution Fedora is available now so I will ask some people who use it to run similar test to check if this issue is still there on the new version.
[30 Nov 2005 15:32] frank homann
i'm experiencing the same problem with mysql 4.1.15 when reaching ~1k q/s on a smp server...
switching to tcp socket is not a practicable solution because it's slower and causes the apache processes to spawn till saturation.
[11 Jul 2006 12:08] Geert Vanderkelen
Hi Julien,

(this bug report has been open to long, sorry about this very late answer..)

Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://dev.mysql.com/doc/ and the instructions on
how to report a bug at http://bugs.mysql.com/how-to-report.php

More details:

Try using the back_log system variable and see if you can repeat the same thing.
I couldn't repeat the effects you see setting that higher.

Cheers,

Geert