Skip to content

Troubleshooting

Session Locking

Symptom: A long-running PHP job eventually makes the server unresponsive and requires a killall lsphp to get back to normal

Potential Cause: The PHP job is locking the PHP session file. Other PHP requests cannot be processed, as they are waiting for the locked session file.

Solution: This issue needs to be addressed within the PHP code itself. If your PHP script is going to be long running, it should create it's own PHP session, or release the session as soon as possible. Long-running PHP scripts should not share PHP sessions with other requests.

If you want more information, here are the steps we have used to diagnose this type of issue.

Run the following command while your long-running PHP script is active, and another request is waiting:

ps -ef | grep php

Make note of the process ID for the waiting request and use it to run the following command (substitute the actual PID for 123456):

strace -tt -T -p 123465

If you see something like this in the output, it indicates that the waiting request is being locked by FD:7:

19:57:13.617826 flock(7, LOCK_EX^Cstrace: Process 123456 detached

Run this command to see what FD:7 is:

lsof -p 123456

You should see output that includes a line like this:

lsphp   414632 nobody    7u   REG                8,5        0  150633 /tmp/sess_4g9st6gmrvvddj15hn7t0b4csl

It indicates that FD:7 is the PHP session file.

If you run the lsof command for the long-running PHP script, you should see the PHP session file, locked at FD:7 in that output as well.