#StackBounty: #php #symfony #locking Can SemaphoreStore Lock be locked infinitely in Symfony?

Bounty: 50

I am using Symfony 5.3 and reading the documentation about expiring locks, it speaks about possible issues with remote locks being locked infinitely:

Locks created remotely are difficult to manage because there is no way
for the remote Store to know if the locker process is still alive. Due
to bugs, fatal errors or segmentation faults, it cannot be guaranteed
that release() method will be called, which would cause the resource
to be locked infinitely.

I intend to use SemaphoreStore , which is a local lock, and would like to know, whether it can happen that a lock is never released, e.g. if the process dies.

use SymfonyComponentLockLockFactory;
use SymfonyComponentLockStoreSemaphoreStore;

$store = new SemaphoreStore();
$factory = new LockFactory($store);

$lock = $factory->createLock('my-semaphore-lock');

if ($lock->acquire()) {

    // if the code dies here before calling release(), or OS kills the process, can the lock be locked forever?

    $lock->release();
}


Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.