sync
sync copied to clipboard
`PosixSemaphore` blocks when there is no space left on device.
The following code:
$semaphore = PosixSemaphore::create(1, permissions: 0600);
will block the current thread forever if there is "no space left on device".
the reason for this seems to be coming from here: https://github.com/amphp/sync/blob/375ef5b54a0d12c38e12728dde05a55e30f2fbec/src/PosixSemaphore.php#L224-L230
the error message for when max queue ids is reached is msg_get_queue(): Failed for key 0x00000000: No space left on device
( replacing 0x00000000
with the currently being tested id ).
which amphp skips in attempt to try another ID.
but there seems to be another problem in this logic: https://github.com/amphp/sync/blob/375ef5b54a0d12c38e12728dde05a55e30f2fbec/src/PosixSemaphore.php#L232-L255
If an identifier exists, but there is no space left on device, the id will not change, Amphp will keep trying to create the queue for the same ID over and over again.