Bug #63087
closedShared locks cannot be released
100%
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
- yes:
- release shared lock and acquire exclusive lock (we are going to write soon)
- if yes:
All lock operations marked either bold or italic, with bold being the ones that make my process stuck.
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
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.
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
Updated by Ludwig Rafelsberger about 10 years ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset 9661e5da2e32d489e4e3bfbb7a7b499daced48da.