Issue Bug Closed

#72043File cache clearing inefficient causing backend timeout

Kees Hoogendijk 12/03/15, 11:40 updated 05/08/16, 21:28

Description

When using the FileBackend for: cache_hash, cache_pages, cache_pagesection, cache_rootline, TYPO3 is inefficient in clearing cache causing massive io action, which can lead to a timeout of the backend. Each time time a page is added, the \TYPO3\CMS\Core\DataHandling\DataHandler will collect all pageId_{uid} tags (from DataHandler:7168 in 6.2.15) that need flushing.
After that, all files in the directories Cache/Data/cache_hash, Cache/Data/cache_pages, Cache/Data/cache_pagesection and Cache/Data/cache_rootline are opened and (though partially) read and compared with the pageId_ tag.
This opening and reading of all files is repeated for each of the collected pageId tags. In my case this can result in over 80000 file_get_content actions in de FileBackend for adding a single page.

In an attempt for a work around I added a TCEMAIN.clearCacheCmd = pages in my pageTSConfig. But in that case, first all sibling pages are collected and those pageId_{uid}‘s are one at the time removed as described above (from DataHandler:7197), after which the entire cache directories are removed without the reading interaction. Resulting in a massive load of pointless io.
To fix this I’ve implemented a hook:

$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['clearCachePostProc'][] to call $this->clear_cacheCmd('pages'); 

before the inefficient cache clearing.

So I in my opinion these 2 things should be fixed:
  1. Can you combine the checking of all these tags so the cache files only need to be read a single time.
  2. Can you perform clearCacheCmd = pages instead of clearing some of the pageId tag before doing the clearCacheCmd = pages afterwards.

Reviews 0

No change resolves or names this issue in its commit message, and no comment links one.