getkirby / kirby

Kirby's core application folder
https://getkirby.com
Other
1.32k stars 169 forks source link

Error deleting cache on high traffic site #6266

Open degoya opened 9 months ago

degoya commented 9 months ago

Description

On our customers high traffic website we get sometime this error messages in the Panel: rmdir(cachefolderpath) Directory is not empty

Expected behavior
Deleting cache without a Error or prevent deleting of not empty folders

Screenshots
grafik or grafik

To reproduce

We where not able to reproduce the error in a local or staging environment by ourselfs. i think the problem is caused by the high traffic. When we remove the cache for 20k+ pages and meanwhile new pages have been cached the folder is not empty and can not be deleted in /vendor/getkirby/cms/src/Filesystem/Dir.php line 553 and causes the error shown above. grafik

Your setup

Kirby Version
4.1.0

silllli commented 8 months ago

I had a similar issue when uploading multiple files on a slow server (https://forum.getkirby.com/t/errors-after-file-image-upload/20900). Each finished upload triggers cache deletion.

degoya commented 7 months ago

i still got this error as soon as i flush the cash. Works great and without errors when there are no visitors on the website. As soon as i got some visitors on the website this causes the shown Error.

distantnative commented 4 months ago

@lukasbestle The only way I currently could imagine to solve this (besides not doing content changes directly on a high-traffic server), would be to introduce a flag on the cache that gets set while flushing. And while the flag is set, any cache updates are ignored (basically while cache is flushing the page remains uncached).

distantnative commented 3 months ago

Where I am struggling: where to put this flag. I think it needs to be a temporary file as it needs to exist across different requests (so not in-memory). But ::flush is removing the whole cache root and recreating it. So any flag file written to root immediately is deleted as well in the process.

degoya commented 3 months ago

Where I am struggling: where to put this flag. I think it needs to be a temporary file as it needs to exist across different requests (so not in-memory). But ::flush is removing the whole cache root and recreating it. So any flag file written to root immediately is deleted as well in the process.

maybe the oposite way, when there is a setting the cache will be written, when the setting is not there the cache won't be written?