Skip to content

File space leak in the lock provider #39826

Open
@Sgeleon2000

Description

@Sgeleon2000

Preconditions and environment

  • Magento version 2.4.7

Steps to reproduce

When using file mode in the file lock provider, the system does not remove the file after use. If there are many variations of the cache hash, the directory size can become very large.

Expected result

The directory where cache files are saved should be small.

Actual result

If there are many variations of the cache hash, the directory size can become very large.

Additional information

To fix this, we can use the following patch:

Index: vendor/magento/framework/Lock/Backend/FileLock.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/vendor/magento/framework/Lock/Backend/FileLock.php b/vendor/magento/framework/Lock/Backend/FileLock.php
--- a/vendor/magento/framework/Lock/Backend/FileLock.php
+++ b/vendor/magento/framework/Lock/Backend/FileLock.php	(date 1738945943083)
@@ -147,6 +147,9 @@

         if (isset($this->locks[$lockFile]) && $this->tryToUnlock($this->locks[$lockFile])) {
             unset($this->locks[$lockFile]);
+
+            $this->fileDriver->deleteFile($lockFile);
+
             return true;
         }


Release note

No response

Triage and priority

  • Severity: S0 - Affects critical data or functionality and leaves users without workaround.
  • Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
  • Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
  • Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
  • Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue: ready for confirmationReported on 2.4.7Indicates original Magento version for the Issue report.Triage: Dev.ExperienceIssue related to Developer Experience and needs help with Triage to Confirm or Reject it

    Type

    No type

    Projects

    Status

    Ready for Confirmation

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions