Issue Bug Closed

#63087Shared locks cannot be released

Ludwig Rafelsberger 11/20/14, 00:14 updated 10/02/18, 11:49

Description

Shared locks using \TYPO3\CMS\Core\Locking\Locker::LOCKING_METHOD_FLOCK can not be released using Locker::release(). (Instead, they will be forcefully released on object destruction, e.g. on request shutdown.)

It seems that the default installation does not require releasing of shared locks, but there are use-cases in which a shared lock must be properly released during a request.

My problematic locking sequence is:
  • acquire shared lock
  • test: is (expensive) resource X cheaply available (cache)?
    • if yes:
      • use it
      • release shared lock
    • if not:
      • release shared lock and acquire exclusive lock (we are going to write soon)
        Obtaining the exclusive lock involves waiting for every other
        lock – shared or exclusive, and especially including our “own” shared one
        from the steps before – to be released
      • repeat the initial test for [cheap variant of] resource X
        (Someone else could have gone through the same process and obtained an
        exclusive lock before us, writing the cheap (cache) variant and superseding
        the need to get the (expensive) resource now.)
        • yes:
          • use it
          • release exclusive lock
        • no:
          • obtain (expensive) resource X
          • store it (cache)
          • use it
          • release exclusive lock

All lock operations marked either bold or italic, with bold being the ones that make my process stuck.

Reviews 2