Project

General

Profile

Actions

Bug #63087

closed

Shared locks cannot be released

Added by Ludwig Rafelsberger about 10 years ago. Updated about 6 years ago.

Status:
Closed
Priority:
Must have
Category:
-
Target version:
-
Start date:
2014-11-19
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
7
PHP Version:
Tags:
Complexity:
easy
Is Regression:
No
Sprint Focus:

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.

Actions #1

Updated by Gerrit Code Review about 10 years ago

  • Status changed from New to Under Review

Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/34374

Actions #2

Updated by Markus Klein about 10 years ago

Well you basically have the classic reader/writer problem here with possible writer starvation. See wikipedia.
Unfortunately I've bad news as flock() is not guaranteed to work in every environment. So please check carefully if flock() is really supported with multiple requests on your server.

Actions #3

Updated by Gerrit Code Review about 10 years ago

Patch set 1 for branch TYPO3_6-2 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/34384

Actions #4

Updated by Ludwig Rafelsberger about 10 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
Actions #5

Updated by Benni Mack about 6 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF