Bug #63087

Shared locks cannot be released

Added by Ludwig Rafelsberger almost 5 years ago. Updated about 1 year ago.

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

100%

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.

Associated revisions

Revision 9661e5da (diff)
Added by Ludwig Rafelsberger almost 5 years ago

[BUGFIX] Correctly remember acquired shared locks

If a shared lock is acquired, that fact must be remembered in the
Locker object, so that it can be properly released later.

Resolves: #63087
Releases: master, 6.2
Change-Id: Ic7b59d3c437a71193c580b279a6795aaad334108
Reviewed-on: http://review.typo3.org/34374
Reviewed-by: Markus Klein <>
Tested-by: Markus Klein <>
Reviewed-by: Alexander Opitz <>
Tested-by: Alexander Opitz <>

Revision c7e8c747 (diff)
Added by Ludwig Rafelsberger almost 5 years ago

[BUGFIX] Correctly remember acquired shared locks

If a shared lock is acquired, that fact must be remembered in the
Locker object, so that it can be properly released later.

Resolves: #63087
Releases: master, 6.2
Change-Id: Ic7b59d3c437a71193c580b279a6795aaad334108
Reviewed-on: http://review.typo3.org/34384
Reviewed-by: Wouter Wolters <>
Reviewed-by: Alexander Opitz <>
Tested-by: Alexander Opitz <>

History

#1 Updated by Gerrit Code Review almost 5 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

#2 Updated by Markus Klein almost 5 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.

#3 Updated by Gerrit Code Review almost 5 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

#4 Updated by Ludwig Rafelsberger almost 5 years ago

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

#5 Updated by Benni Mack about 1 year ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF