Bug #57136

Mitigate race condition when clearing file caches

Added by Helmut Hummel over 5 years ago. Updated about 2 years ago.

Status:
Closed
Priority:
Must have
Assignee:
-
Category:
-
Target version:
Start date:
2014-03-21
Due date:
% Done:

100%

TYPO3 Version:
6.2
PHP Version:
Tags:
Complexity:
Is Regression:
No
Sprint Focus:

Description

When file caches are flushed, the cache directory is also deleted.

Now when a second request comes in and creates the caches
it happens that the cache directory of a given cache is still there
for this cache when calling setCache in the SimpleFileBackend,
but is deleted by the first request afterwards.

Now the cache directory for the second request does not exist
and setting cache entries will fail.

Debug trace of the two requests:

[21-Mar-2014 10:50:14 Europe/Berlin] 532c0b566855e setCache
[21-Mar-2014 10:50:14 Europe/Berlin] 532c0b566855e setCache
[21-Mar-2014 10:50:14 Europe/Berlin] 532c0b5674733 setCache
[21-Mar-2014 10:50:14 Europe/Berlin] 532c0b5674733 setCache
[21-Mar-2014 10:50:14 Europe/Berlin] 532c0b566855e setCache
[21-Mar-2014 10:50:14 Europe/Berlin] 532c0b5674733 setCache
[21-Mar-2014 10:50:14 Europe/Berlin] 532c0b566855e setCache
[21-Mar-2014 10:50:14 Europe/Berlin] 532c0b566855e setCache
[21-Mar-2014 10:50:14 Europe/Berlin] 532c0b566855e setCache
[21-Mar-2014 10:50:14 Europe/Berlin] 532c0b566855e flush /htdocs/master/typo3temp/Cache/Code/cache_core/
[21-Mar-2014 10:50:14 Europe/Berlin] 532c0b566855e create /htdocs/master/typo3temp/Cache/Code/cache_core/
[21-Mar-2014 10:50:14 Europe/Berlin] 532c0b566855e flush /htdocs/master/typo3temp/Cache/Data/cache_classes/
[21-Mar-2014 10:50:14 Europe/Berlin] 532c0b5674733 exception 
[21-Mar-2014 10:50:14 Europe/Berlin] 532c0b5674733 exception 
[21-Mar-2014 10:50:14 Europe/Berlin] PHP Fatal error:  Uncaught exception 'TYPO3\CMS\Core\Error\Exception' with message 'PHP Warning: file_put_contents(/htdocs/master/typo3temp/Cache/Data/cache_classes/532c0b56e0596.temp): failed to open stream: No such file or directory in /TYPO3/master/typo3/sysext/core/Classes/Cache/Backend/SimpleFileBackend.php line 246' in /TYPO3/master/typo3/sysext/core/Classes/Error/ErrorHandler.php:111
Stack trace:
#0 [internal function]: TYPO3\CMS\Core\Error\ErrorHandler->handleError(2, 'file_put_conten...', '/Volumes/Data/U...', 246, Array)
#1 /TYPO3/master/typo3/sysext/core/Classes/Cache/Backend/SimpleFileBackend.php(246): file_put_contents('/Volumes/Data/U...', '/Volumes/Data/U...')
#2 /TYPO3/master/typo3/sysext/core/Classes/Cache/Frontend/StringFrontend.php(60): TYPO3\CMS\Core\Cache\Backend\SimpleFileBackend->set('typo3_cms_core_...', '/Volumes/Data/U...', Arra in /TYPO3/master/typo3/sysext/core/Classes/Error/ErrorHandler.php on line 111
[21-Mar-2014 10:50:15 Europe/Berlin] 532c0b566855e create /htdocs/master/typo3temp/Cache/Data/cache_classes/
[21-Mar-2014 10:50:15 Europe/Berlin] 532c0b566855e flush /htdocs/master/typo3temp/Cache/Data/l10n/
[21-Mar-2014 10:50:15 Europe/Berlin] 532c0b566855e create /htdocs/master/typo3temp/Cache/Data/l10n/
[21-Mar-2014 10:50:15 Europe/Berlin] 532c0b566855e flush /htdocs/master/typo3temp/Cache/Code/cache_phpcode/
[21-Mar-2014 10:50:15 Europe/Berlin] 532c0b566855e create /htdocs/master/typo3temp/Cache/Code/cache_phpcode/
[21-Mar-2014 10:50:15 Europe/Berlin] 532c0b566855e flush /htdocs/master/typo3temp/Cache/Code/fluid_template/
[21-Mar-2014 10:50:15 Europe/Berlin] 532c0b566855e create /htdocs/master/typo3temp/Cache/Code/fluid_template/

Mitigate this by immediately recreating the cache directory

debug-race-condition.diff View (3.6 KB) Helmut Hummel, 2014-03-21 11:04

slow-down-flush.diff View (546 Bytes) Helmut Hummel, 2014-03-21 12:58

Associated revisions

Revision e7eae905 (diff)
Added by Helmut Hummel over 5 years ago

[BUGFIX] Mitigate race condition on cache flush

When file caches are flushed, the cache directory
is also deleted.

Now when a second request comes in and creates
the caches it happens that the cache directory of
a given cache is still there for this cache when
calling setCache in the SimpleFileBackend,
but is deleted by the first request afterwards.

Now the cache directory for the second request
does not exist and setting cache entries will fail.

Mitigate this by immediately recreating
the cache directory.

Resolves: #57136
Releases: 6.2
Change-Id: I3c4c5c63c6c754447549285d9718798272f9e585
Reviewed-on: https://review.typo3.org/28594
Reviewed-by: Ernesto Baschny
Reviewed-by: Thomas Maroschik
Reviewed-by: Pascal Dürsteler
Reviewed-by: Markus Klein
Tested-by: Markus Klein
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn

History

#1 Updated by Helmut Hummel over 5 years ago

  • File debug-race-condition.diff added

#2 Updated by Helmut Hummel over 5 years ago

  • File deleted (debug-race-condition.diff)

#4 Updated by Gerrit Code Review over 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 https://review.typo3.org/28594

#6 Updated by Helmut Hummel over 5 years ago

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

#7 Updated by Riccardo De Contardi about 2 years ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF