Skip to content

Commit

Permalink
Avoid throwing errors when clearing cache dirs fails
Browse files Browse the repository at this point in the history
For high traffic sites the cache folder may be written to while
the current process is busy removing cache files. This results
in the inability to remove the cache folder which was presumed
to be empty.
We catch this case and simple ignore the error as the old cache
files have already been successfully removed.
  • Loading branch information
am0s committed Sep 23, 2020
1 parent 69deb64 commit 229d919
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion kernel/classes/ezsubtreecache.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,17 @@ static function removeExpiryCacheFromDisk( $expiryCachePath )
// in the database to determine if the cache is expired.
// This reduces the need to perform expensive modifications to the
// database entries for the cluster storage.
$fileHandler->fileDelete( $expiryCachePath );
try {
$fileHandler->fileDelete( $expiryCachePath );
} catch (\ErrorException $e) {
// Check if error relates to not being able to remove non-empty dirs.
// This can happen if clearing occurs at the same time as an active request writes new caches,
// which is not uncommon for high traffic sites.
if (!preg_match("|directory not empty|i", $e->getMessage())) {
throw $e;
}
// else: Ignore error
}
}
}
}
Expand Down

0 comments on commit 229d919

Please sign in to comment.