Issue Bug Closed

#100123Regular exceptions due to dependency injection (di) cache

Sybille Peters 03/09/23, 06:20 updated 09/29/26, 07:13

Description

I have regular error messages in the logs due to Dependency Injection cache /var/cache/code/di. This improved considerably, after switching from shared (NFS) to the VM storage, but has not disappeared.

This also results in error message when loading a page in frontend. When page is loaded again, it is ok. Since (page) cache is warmed up at night and after deployment, these errors are usually not noticed, but it does happen.

Switching to non-NFS:

- entire var/cache/code switched to local storage
- when deploying, system cache on all machines must be flushed (and opcache also, of course)
- cache is warmed up during deployment (“@php vendor/bin/typo3 cache:warmup”)

The number of log messages with these errors are reduced. Last time I checked, I had roughly 60, all with nearly same timestamp (within 20 seconds).

setup

  • TYPO3 11.5.24
  • dual machines behind load-balancer, however currently only one at a time utilized, other is fallback
  • uses the defaults for caching, except what is usually in the DB is in Redis and b13/distributed-locking is used for shared locking. var/cache/di is switched to local storage

Logs

*ssl_access.log*
1)
“Call to a member function resolvePackagePath”

Thu Mar 02 05:26:22 2023] [error] [pid 18699] mod_proxy_fcgi.c(851): [client 54.36.148.228:29271] AH01071: Got error 'PHP message:
PHP Fatal error:  Uncaught Error: Call to a member function resolvePackagePath()
on null in
/var/www/mysite/releases/1/public/typo3/sysext/core/Classes/Utility/ExtensionManagementUtility.php:135

TYPO3 log (logfile if default LogWriter is used, usually in var/log or typo3temp/var/log)

2)

“The temporary cache file .*cache/code/di/.*could not be written”

Thu, 02 Mar 2023 23:36:22 +0100 [CRITICAL] request="825e1a685dff9" component="TYPO3.CMS.Core.Error.ProductionExceptionHandler":
Core: Exception handler (WEB: BE): TYPO3\CMS\Core\Cache\Exception, code #1334756737,
file /var/www/www.uni-oldenburg.de/releases/115/htdocs/typo3/sysext/core/Classes/Cache/Backend/SimpleFileBackend.php, line 232:
The temporary cache file "/var/www/www.uni-oldenburg.de/releases/115/var/cache/code/di/640124e6f2270786869194.temp" could not be written. - {"mode":"WEB","application_mode":"BE","exception_class":"TYPO3\\CMS\\Core\\Cache\\Exception","exception_code":1334756737,"file":"/var/www/www.uni-oldenburg.de/releases/115/htdocs/typo3/sysext/core/Classes/Cache/Backend/SimpleFileBackend.php","line":232,"message":"The temporary cache file \"/var/www/www.uni-oldenburg.de/releases/115/var/cache/code/di/640124e6f2270786869194.temp\" could not be written.","request_url":"https://mysite/","exception":null}

3)
“Class ‘DependencyInjectionContainer_[0-9a-f]*’ not found”

Fri, 03 Mar 2023 00:11:29 +0100 [CRITICAL] request="91d0aa2d1ff6e" component="TYPO3.CMS.Core.Error.ProductionExceptionHandler": Core: Exception handler (WEB: BE): Error, code #0, file /var/www/www.uni-oldenburg.de/releases/115/htdocs/typo3/sysext/core/Classes/DependencyInjection/ContainerBuilder.php, line 98: Class 'DependencyInjectionContainer_dfe57bd75f64f6fcd823c25279efdcb969473f70' not found - {"mode":"WEB","application_mode":"BE","exception_class":"Error","exception_code":0,"file":"/var/www/www.uni-oldenburg.de/releases/115/htdocs/typo3/sysext/core/Classes/DependencyInjection/ContainerBuilder.php","line":98,"message":"Class 'DependencyInjectionContainer_dfe57bd75f64f6fcd823c25279efdcb969473f70' not found","request_url":"https://mysite/","exception":null}

Reviews 1

History 6

  1. Stephan Großberndt commented <span data-processor="relativetime" data-value="2024-01-17T09:26:43+00:00" > 01/17/24, 09:26 </span>

    Same issue here, I also have the issue exactly like you with multiple hosts for high availability, but additionally I also have it on at least one instance without a load balancing setup. TYPO3 11.5.33

    Core: Exception handler (WEB): Uncaught TYPO3 Exception: Class 'DependencyInjectionContainer_f256ee52bc9d8ee1296f6d6a4fd948bd1efbc7c3' not found | Error thrown in file /var/www/domain/releases/185/private/typo3/sysext/core/Classes/DependencyInjection/ContainerBuilder.php in line 98. Requested URL: xxx
    
    Core: Exception handler (WEB): Uncaught TYPO3 Exception: #1334756737: The temporary cache file "/var/www/doman/releases/185/var/cache/code/di/65a7681100488496629287.temp" could not be written. | TYPO3\CMS\Core\Cache\Exception thrown in file /var/www/domain/releases/185/private/typo3/sysext/core/Classes/Cache/Backend/SimpleFileBackend.php in line 232. Requested URL: xxx
  2. Ulrich Mathes commented <span data-processor="relativetime" data-value="2024-04-26T13:19:38+00:00" > 04/26/24, 13:19 </span>

    We have this problem after deployment. file_put_contents only works when the directory is already present and writable.

    Maybe the file_put_contents should be hardend with GeneralUtility::mkdir_deep.
    On the other Hand, SimpleFileBackend::setCache() handles the creation of the cache directory.

    This problem does apply to TYPO3 12 and 13.

    —-

    In both error logs presented before, we see that these instances also are placed in releases folders. So maybe this is a hint in the right direction.

    Our deployment does not copy /var from the current release to the new one as we want a fresh instance. So in deployment this folder might not be present in some point.

    A look in our deployment shows the following sequence:
    1. composer install in docker container
    2. rsync
    3. symlink
    4. extension:setup
    5. cachetool:clear:opcache
    6. cache:flush
    7. cache:warmup
    In ddev with var/cache deleted before executing each step:
    1. folder not created, no error
    2. does not apply here
    3. sets up the folder, no error
    4. does not apply here
    5. sets up the folder, no error
    6. sets up the folder, no error

    I could think of requests started between symlink is switched and extension:setup.
    Maybe we should change the order and take care that the folder is present before switching the symlink.

  3. Georg Ringer commented and changed status New Closed <span data-processor="relativetime" data-value="2026-09-28T20:47:43+00:00" > 09/28/26, 20:47 </span>

    closing this issue as solved with #91768. if still valid for you in v14, please open a new issue and provide information to reproduce it.

  4. Stephan Großberndt commented <span data-processor="relativetime" data-value="2026-09-29T07:13:24+00:00" > 09/29/26, 07:13 </span>

    Georg Ringer wrote in #note-5:
    > closing this issue as solved with #91768. if still valid for you in v14, please open a new issue and provide information to reproduce it.

    The bugfix has also been backported to v13 in v13.4.4 with 87644: [BUGFIX] Prevent race condition while writing file caches and thus should not be reproducible there as well.