title: Apache/PHP processes hanging while interacting with MySQL
body: <p>We're seeing some strange behaviour and we're not sure if it's a problem with apache, php, mysql or the OS, so over to the big brains of stackoverflow!</p>
  
  <p>We have Apache and mod_php talking to a mysql5 server. Sometimes, a process will choose to hang, trying to read from a file descriptor.</p>
  
  <p>Firing up strace one on of them (all hanging processes showed the same results) gave this :</p>
  
  <pre><code>[root@prweb133v ~]# strace -p 8450
  Process 8450 attached - interrupt to quit
  read(57,  &lt;unfinished ...&gt;
  </code></pre>
  
  <p>So what was it trying to read?</p>
  
  <pre><code>[root@prweb133v ~]# lsof -p 8450
  ...
  ...
  httpd   8450 apache   57u  IPv4    5546599             TCP
  prweb133v.local:36615-&gt;hadat.local:mysql (ESTABLISHED)
  </code></pre>
  
  <p>That's our mysql server! Ok, so maybe it was trying to read the results of a query, I thought. Checking the processlist on the mysql server, the connection was established but in a state of SLEEP. </p>
  
  <p>Hmmmm.</p>
  
  <p>So then I checked netstat to see who was trying to send/receive what.</p>
  
  <p>On the webserver :</p>
  
  <pre><code>[root@prweb133v ~]# netstat -t -n -a | grep 36615
  tcp        0      5 172.23.179.6:36615          172.23.179.67:3306         
  ESTABLISHED 
  </code></pre>
  
  <p>and on the mysql server there was an established connection but 0 in the send or receive queues.</p>
  
  <p>Any idea what these mysterious 5 bytes could be, or why they randomly don't get the the mysql server?</p>
  
  <p>Cheers!</p>
  
  <p>Mike</p>