Problem/Motivation

I have been experimenting running Drupal with FrankenPHP in worker mode, which is a persistent app server (the container is not reset between requests).

Executing multiple drush commands in behat gave me an OOM error, which I traced to metatag_views module.

metatag_views calls $view->preExecute() but not $view->postExecute(). preExecute() pushes
the previous $GLOBALS['_current_view'] onto $view->old_view and sets the global to this view; only postExecute() pops it back.

As a result, after a metatag page-attachment render on a Views page, the global keeps the view. The next such render chains it into old_view, which builds a list that grows forever and pins every service container the views were built with.

Measured: about 25 MB of additional RAM used per container rebuild, reaching 1 GB in a 500-request worker lifetime.

Proposed resolution

Call postExecute() to clean up.

CommentFileSizeAuthor
#8 3626128.png97.3 KBcsakiistvan

Issue fork metatag-3626128

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

ptmkenny created an issue. See original summary.

ptmkenny’s picture

Title: metatag_views calls $view->preExecute() but not $view->postExecute() » metatag_views calls $view->preExecute() but not $view->postExecute(), leading to OOM error
ptmkenny’s picture

Status: Active » Needs review

Tests are not passing, but that appears to be due to the new D12 attributes requirements and migrate module deprecation, so I'm tentatively setting to "Needs review."

ptmkenny’s picture

csakiistvan’s picture

Assigned: Unassigned » csakiistvan
csakiistvan’s picture

Assigned: csakiistvan » Unassigned
Status: Needs review » Reviewed & tested by the community
StatusFileSize
new97.3 KB

✅ Tested and works — applied MR !273, rebuilt caches and called metatag_views_get_view_tags() five times in one drush process: the old_view chain behind $GLOBALS['_current_view'] grew by one per call before the fix and stays at 0 after it. The leak is fixed, and FrankenPHP is not needed to reproduce it.

damienmckenna made their first commit to this issue’s fork.

damienmckenna changed the visibility of the branch 2.2.x to hidden.

damienmckenna’s picture

damienmckenna’s picture

Status: Reviewed & tested by the community » Fixed

Committed.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.