#91768Race condition while caching data using SimpleFileBackend
Description
When two requests run at the same time:
- request A clears a cache (e.g. cache_core)
- request B tries to write into the same cache
In this situation, request B may fail because the parent folder is gone:
[06-Jul-2020 17:54:02] WARNING: [pool www] child 4978 said into stderr: "NOTICE: PHP message: https://example.host/ - core: Core: Error handler (FE): PHP Warning: file_put_contents(/var/www/html/html/typo3temp/var/Cache/Data/l10n/5f03491aac1d8038441429.temp): failed to open stream: No such file or directory in /var/www/html/vendor/typo3/cms/typo3/sysext/core/Classes/Cache/Backend/SimpleFileBackend.php line 236" [06-Jul-2020 17:54:02] WARNING: [pool www] child 4978 said into stderr: "NOTICE: PHP message: https://example.host/ - Core: Exception handler (WEB): Uncaught TYPO3 Exception: #1334756737: The temporary cache file "/var/www/html/html/typo3temp/var/Cache/Data/l10n/5f03491aac1d8038441429.temp" could not be written. | TYPO3\CMS\Core\Cache\Exception thrown in file /var/www/html/vendor/typo3/cms/typo3/sysext/core/Classes/Cache/Backend/SimpleFileBackend.php in line 239. Requested URL: https://example.host/home/"
This seems to happen more often on non-local filesystems because they are slower. However, it could also happen when using a local temp folder.
Reviews 3
Related issues 6
- Bug #33622Filebackend reports error when trying to rename file due to concurrent processes
- Bug #87174.... typo3temp/var/cache/code/cache_core/site-configuration.php): Access is denied
- Task #88927The temporary cache file ... could not be written
- Bug #99821cache:warmup always recreates core code cache files even if they exist and the content will not change
- Bug #100123Regular exceptions due to dependency injection (di) cache
- Task #105101Log instead of throw errors on failed cache file creation