-
Notifications
You must be signed in to change notification settings - Fork 9.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When using file storage for the lock provider, we get an ever growing directory of files without any cleanup happening #39369
Comments
Hi @hostep. Thank you for your report.
Join Magento Community Engineering Slack and ask your questions in #github channel. |
Performed some statistics calculations across the projects we maintain ourselves. These are the number of lock files found across the production versions of these shops, per Magento version. All our shops on Magento 2.4.7 got the temporary workaround to delete lock files if they haven't been touched in 10 days. Without this workaround the numbers would exceed 1 million.
So we can indeed see a slight increase of number of lock files used since Magento 2.4.6 which can be explained in a lock file per order being needed now. |
Suggestion for the simple solution, to cleanup old lock files using a cronjob: #39372 This is probably only a partial fix for this issue, it's a cleanup afterwards, maybe we can also already beforehand try to prevent writing too many files somehow... |
Hi @engcom-Hotel. Thank you for working on this issue.
|
Hello @hostep, Thanks for the report and collaboration! The issue has been reproducible for us. Hence confirming this issue. Thanks |
✅ Jira issue https://jira.corp.adobe.com/browse/AC-13367 is successfully created for this GitHub issue. |
✅ Confirmed by @engcom-Hotel. Thank you for verifying the issue. |
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: