When using file storage for the lock provider, we get an ever growing directory of files without any cleanup happening #39369
Labels
Issue: ready for confirmation
Reported on 2.4.x
Indicates original Magento version for the Issue report.
Preconditions and environment
Steps to reproduce
var/locks
directoryIdeally you should look at a shop running for many months and where file based locking has been enabled, and inspect the directory that contains those lock files.
Expected result
var/locks
directory should not overflow with an ever increasing amount of filesActual result
var/locks
can contain up to millions of files after several months of running a Magento shopExample filenames:
We had one project that had 3.5 million files in that directory, up to a point where the filesystem started complaining with errors like
Failed to open stream: No space left on device
every time a lock file was needed (there was plenty of disk space, it's just that a directory can't handle that large amount of files in one directory). Another project had 1.9 million files and another had ~170.000 files.So that's really bad. We need some kind of bugfix or cleanup mechanism to keep this under control.
Additional information
The locking mechanism in Magento is used for various things:
Most of these things result in lock names that are predictable and remain the same over time:
However, some of these are pretty dynamic and those names can change over time:
getCacheKeyInfo
is called and that gets hashed and that hash is being used for the lock name, sometimes with a suffix for thefinal_price
blocks that contain ID's and dates and currencies and so onMore observations:
/var/www/html/release123/
, the next one in/var/www/html/release124/
, and it turns out that one of the parameters to generate a lock name contains the absolute path to template files, so for each deploy that path changes and the lock name changes as well, so we get an ever growing, never stopping, number of lock files after each deployPossible solutions:
LockGuardedCacheLoader
, we can mark those as temporary (if file storage is used) and to be removed immediately after they have been unlocked. No idea if this is a good idea and won't lead to race conditions or other problemsenv.php
should be added to determine what lock storage we should use for theLockGuardedCacheLoader
, Adobe specifially disabled the database one in 2.4.7, for Galera clusters as they have issues with this for some reason, but if this would be configurable and we could choose ourselves what locking mechanism should be used for theLockGuardedCacheLoader
, then we can already prevent a big deal of lock files being written to the filesystemThese are just some random ideas, in case other people have other suggestions, feel free to let me know in the comments below.
Temporary solution:
Setup something like this in the
crontab
on your server:Thanks!
Release note
No response
Triage and priority
The text was updated successfully, but these errors were encountered: