Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

semaphore keys lost after some time

I have a parent-child processes using shared memory. Child put data into shared memory about 10 times per second. Parent and child are using semaphore to lock resource while writing/reading. This solution works for several hours and then I start getting warnings:

PHP Warning: sem_acquire(): failed to acquire key 0x4101f1fb: Invalid argument in script.php on line 350
PHP Warning: sem_release(): SysV semaphore 140105644163240 (key 0x4101f1fb) is not currently acquired in script.php on line 354

It looks like the script is over some limit and semaphore destroyed, but I can't find anything in ipcs referring to the current limits/use.

I also tried to sem_get in order to get new semaphore ID but I can't pass it to child via shared memory shm_put_var is not working with resources.

What is the best way to handle semaphores in that long run processes?

like image 416
J.T Avatar asked Feb 24 '18 08:02

J.T


1 Answers

Could be an ever-existing bug in PHP:

https://bugs.php.net/bug.php?id=44109

The first (and only) comment speaks of ~32000 semaphore identifiers and that the number is not adjustable...

like image 175
Honk der Hase Avatar answered Oct 03 '22 02:10

Honk der Hase