Review main Abandoned

86020[TASK] Log instead of throwing errors on failed cache file creation

Mathias Brodala CR 0 V 0 Easy +8 −4 updated 04/10/25, 08:42

Commit message

Instead of throwing an exception, an error is now logged, as the cache
creation failure must not abort the current request
(the request can still be served).

Review

  • Code review CR 0
  • Verified V 0

Issues 2

Files 1

Review log 1924

  1. Mathias Brodala uploaded patch set 1 09/11/24, 14:16

  2. core-ci voted on patch set 1 V -1 09/11/24, 14:26 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/65462

  3. core-ci voted on patch set 1 V +1 09/11/24, 14:37 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/65462

  4. Benni Mack commented on patch set 1 09/11/24, 15:08

    this is a chicken egg problem: if the "core" cache cannot be flushed, because e.g. it is currently unavailable, the Logger might not be available as the information is not set up yet...
  5. Mathias Brodala commented on patch set 1 09/12/24, 06:30

    Reply

    Hm, can you elaborate on that? How is the logger related to caching?
  6. Benni Mack commented on patch set 1 CR +1 09/24/24, 09:40

    Reply

    forget my comment, just tested and my comment does not make sense.
  7. Benjamin Franzke commented on patch set 1 CR -1 09/24/24, 10:21

    I don't think this fixes the race condition mentioned in https://forge.typo3.org/issues/91768 – it is only silencing the race condition. The race condition happens because the folders are removed with set() is called. That means the real fix for the issue is to remove cache files only, no directories in `flush()`. This change is still fine for me (no need for an exception), but it should resolve a separate task and mark this one as `Related`.

    SimpleFileBackend.php:232

    Can we agree that this is an `error` instead of `warning`? Because this means the system is not properly setup or in a mode where disk is full or so, right? From LoggerInterface.php: warning: > Use of deprecated APIs, poor use of an API, undesirable things that are not necessarily wrong. error: > Runtime errors that do not require immediate action but should typically be logged and monitored.
  8. Benjamin Franzke commented on patch set 1 09/24/24, 10:22

    Reply

    > removed with set() is called typo, meant: "removed (by another process) while set() is called"
  9. Mathias Brodala commented on patch set 1 09/24/24, 10:27

    SimpleFileBackend.php:232 Reply

    Totally fine with me. I didn't pick the level strictly from the LoggerInterface definitions but more like "warning = recoverable error".
  10. Mathias Brodala commented on patch set 2 CR +1 V +1 09/24/24, 10:28

    Published edit on patch set 1.
  11. core-ci voted on patch set 2 V +1 09/24/24, 10:37 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/66486

  12. Benjamin Franzke uploaded patch set 3 V +1 09/24/24, 10:51

  13. Benjamin Franzke commented on patch set 3 09/24/24, 10:51

    Reply

    Done

    SimpleFileBackend.php:232 Reply

    Done
  14. core-ci voted on patch set 3 V +1 09/24/24, 10:56 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/66488

  15. Mathias Brodala commented on patch set 3 09/24/24, 11:04

    Reply

    Thanks!
  16. Benjamin Franzke uploaded patch set 4 V +1 09/24/24, 11:05

  17. Benjamin Franzke commented on patch set 4 09/24/24, 11:05

    SimpleFileBackend.php:228

    file_put_contents procudes E_WARNING, which will run through the core ErrorHandler. We don't want this, since the log an own error here… I therefore added `@`.
  18. core-ci voted on patch set 4 V +1 09/24/24, 11:10 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/66489

  19. Benjamin Franzke commented on patch set 4 CR 0 V -1 09/24/24, 11:17

    Hm... Sorry, I'm still not happy with it, because we have no way to signal the error besides using logging now. That means: If the disk becomes full (during cache warmup) we won't notice, but exit with `0` in `typo3 cache:warmup`.
  20. Mathias Brodala commented on patch set 4 09/24/24, 12:14

    Reply

    Maybe we need to use https://www.php.net/error_get_last to behave differently depending on the kind of error …
  21. Benjamin Franzke commented on patch set 4 09/24/24, 12:32

    Reply Unresolved

    I would be grateful if you could try out the following approach for avoiding the race condition: > [BUGFIX] Prevent race condition while writing file caches | https://review.typo3.org/c/Packages/TYPO3.CMS/+/86296 …in the scenario where you can (hopefully) reliably reproduce the race condition(s) (as mentioned in https://forge.typo3.org/issues/91768#note-4 )
  22. Mathias Brodala marked it work in progress 09/24/24, 13:55

  23. Benni Mack updated the commit message in patch set 5 V +1 10/18/24, 13:55

  24. Benjamin Franzke abandoned the change 04/10/25, 08:42

    Superseded by 86296: [BUGFIX] Prevent race condition while writing file caches | https://review.typo3.org/c/Packages/TYPO3.CMS/+/86296