I have a long-running PHP application that spawns multiple child processes to run tasks on a CentOS VM, and it uses the SysV IPC message queue (via msg_get_queue(), etc) for sending events to the parent process.
The problem is that even though the children nicely execute msg_remove_queue() prior to exiting, message resources seem to stick around at the system level. Eventually this fills up the message queue until it reaches kernel.msgni.
The funny thing is that when I run
ipcs
as the user this script runs under, I see the message queues appearing and disappearing as expected. However, when I run the same command as root, the list of queues slowly and continuously grows, with many of these in the list:
0x00000000 1031634944 <user> 0 0 0
I'm not an expert with the SysV message queue, so I'm a little unsure of the best solution here, or whether there is a good solution. For the time being, I have set kernel.msgni to 100,000(!). I'm unsure if this is a good idea on a 1GB box.
Note that the permissions are 0 and bytes used is also 0. So theoretically these queues are not taking up any space, although at some point I would expect that just having the system iterate over these is a load on the system.
My questions are:
- Why is this happening?
- Will these resources ever expire, time out or otherwise disappear?
- Is there some solution I'm not seeing?