Comment 0 for bug 1327946

Revision history for this message
Joshua Harlow (harlowja) wrote :

If a program is terminated via ctrl-c or other signal and it has acquired locks using the posix_ipc sempahore those sempahores are never released (unlike the filelock which does release automatically on program termination). This can be easily seen by trying the following in a shell (see below). You can come back after minutes and hours and try to acquire the abandoned semaphore and still be unable to (its still busy), perhaps there is a automatic timeout that needs to be provided? I can imagine that if people do upgrades of a service using this lock and the program is currently locked that they would have to have some kind of sempahore cleaning script to even restart that application (which seems bad).

Python 2.7.6 (default, Mar 22 2014, 22:59:56)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from openstack.common import lockutils
>>> import os
>>> os.getpid()
16123
>>> lockutils.InterProcessLock("testing")
<openstack.common.lockutils._PosixLock object at 0x7f8bb4a8e210>
>>> a = lockutils.InterProcessLock("testing")
>>> a.acquire()
<openstack.common.lockutils._PosixLock object at 0x7f8bb30e7ad0>
>>> exit()
(.dev)josh@lappy:~/Dev/oslo-incubator$ python
Python 2.7.6 (default, Mar 22 2014, 22:59:56)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from openstack.common import lockutils
>>> import os
>>> os.getpid()
16128
>>> a = lockutils.InterProcessLock("testing")
>>> a.acquire(timeout=5)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "openstack/common/lockutils.py", line 168, in acquire
    self.semaphore.acquire(timeout)
posix_ipc.BusyError: Semaphore is busy
....