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.
| Comment | File | Size | Author |
|---|---|---|---|
| #8 | 3626128.png | 97.3 KB | csakiistvan |
Issue fork metatag-3626128
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
Comment #3
ptmkenny commentedComment #4
ptmkenny commentedComment #5
ptmkenny commentedTests 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."
Comment #6
ptmkenny commentedAh, tests are broken by #3625969: Twig's 3.30 TypeError: Twig\Runtime\EscaperRuntime::escape(): Argument #4 ($autoescape) must be of type bool, null given, nothing to do with this.
Comment #7
csakiistvanComment #8
csakiistvan✅ Tested and works — applied MR !273, rebuilt caches and called
metatag_views_get_view_tags()five times in one drush process: theold_viewchain 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.Comment #11
damienmckennaComment #13
damienmckennaCommitted.