title: Apache locks session files for no reason
body: <p>I keep running into stale, locked, (php) session files on my apache server which keep the threads from closing and thus eating away my server resources.</p>
  
  <p>Its an Ubuntu box and having session_write_close(); in the automatically appended script doenst help. I keep ending up with locked session files which are local (memory disk) and with no other processes trying to access it... </p>
  
  <p>I just dont know where to look anymore...</p>
  
  <hr>
  
  <p>To clearify things a bit:</p>
  
  <ul>
  <li>we're running ubuntu stock apache2 (MPM prefork i believe) with standard PHP session handling</li>
  <li>the sessions are stored on a ramdrive so fsck-ing the thing wont do much ;)</li>
  </ul>
  
  <p>The problem arises inconsistently and on different time intervals. But after looking at the open files (via <code>lsof | grep sess_</code>) i keep seeing apache2 threads holding on to those files.</p>
  
  <pre><code>apache2   28405 www-data   30uW     REG               0,18     38652    2737432 /data/ramdrive/sess_8f95700e5d2ed8daf2e2d12625ed7d53
  </code></pre>
  
  <p>Since i dont have the issue ATM i have no actual live data, but it looked something like this:
  doing an strace -p on the aforementioned id
  i would see something in the line of </p>
  
  <pre><code>F_LOCK(30, 
  </code></pre>
  
  <p>something... 
  doing an <code>ls -l /proc/[apache pid]/fd/30</code>
  (BTW everytime its always 30!) it would point to some session file</p>
  
  <p>The actual file contained no weird stuff and looked pretty sane... </p>
  
  <p>Does the fact that when it happened all FD's pointed to 30 (so it would end up being <code>/proc/123123/fd/30</code> and <code>/proc/123124/fd/30</code> etc) does that have to do with anything?</p>