Domain Source - for many contents crash site

Created on 17 November 2023, 12 months ago

Drupal Version

drupal 10.1.6

Domain module version

domain 2.0.x-dev

Expected Behavior

I would like to activate the domain scource module, but after activating the module, the contents are not available on the site.

Actual Behavior

PHP message: PHP Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 262144 bytes) in /core/lib/Drupal.php on line 554; PHP message: PHP Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 262144 bytes) in Unknown on line 0; PHP message: PHP Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 262144 bytes) in Unknown on line 0; PHP message: PHP Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 262144 bytes) in Unknown on line 0, referer: /admin/content

PHP Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 20480 bytes) in /core/lib/Drupal/Core/TypedData/DataDefinition.php on line 263; PHP message: PHP Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 20480 bytes) in /web/core/lib/Drupal/Core/Session/SessionHandler.php on line 79; PHP message: PHP Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 20480 bytes) in /core/includes/errors.inc on line 26, referer: /admin/content

Steps to reproduce

There is a lot of content on the site, hundreds. After I turn on the Domain source module, the page completely crashes.

πŸ’¬ Support request
Status

Needs review

Version

2.0

Component

- Domain Source

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @intradavid
  • πŸ‡«πŸ‡·France mably

    Lots of links on your pages?
    DomainSourcePathProcessor service is rather resource hungry for example.
    It easily takes 100MB of memory to process some pages on some of our sites.
    Profiling using XHProf shows that rendering links can take more than 60% of total processing time, amazing.
    We also have DomainEntitySourcePathProcessor service activated for handling taxonomies, so that doesn't help ;)

  • Yes, there are quite a lot of links on the page, what is the solution to make it work?

    path_alias = 291,340

  • πŸ‡«πŸ‡·France mably

    291,340 is that the number of links you are trying to display on a single page?

  • No, these are all the URLs used by the site.

    Interestingly, the same problem occurs even if I just want to edit a content.

    Basically, there is no problem, only after I turn on the Domian source module, I can't view or edit any single content.

  • /modules/contrib/domain/domain_source/src/HttpKernel/DomainSourcePathProcessor.php

    This line eating my memory, when remove all working fine.

    $url = Url::fromUserInput($alias, $options);

  • πŸ‡«πŸ‡·France mably

    @intradavid, that's definitely the hotspot we identified on our side too, so we override this service to filter out the urls we don't want to analyze.

    It would definitely be interesting to be able to filter out some url patterns, for our use case at least.

  • mably, How can I help you solve this?

  • Status changed to Active 12 months ago
  • πŸ‡ΊπŸ‡ΈUnited States agentrickard Georgia (US)

    Housekeeping first.

    * Support requests are never flagged as "Needs review" -- that is reserved for patches or merge requests.
    * When you comment out $url = Url::fromUserInput($alias, $options);, nothing will happen. Its like uninstalling the module.

    I think the root question here is *why* are so many links being generated on a page?

    If these were mostly admin links (such as from Admin Toolbar), we could pretty easily exclude those.

    1. If these are all node links, what is it about the site that causes this issue?
    2. Lots of blocks that load all content? Unlimited pagers?
    3. Headless Drupal using JSONAPI to deliver all content?

    @intradavid -- from a testing perspective against a standard Drupal install, Devel Generate could easily create 300,000 nodes with aliases (though that might take a while).

    From a development perspective, it would be ideal if we could cache this data -- the problem being that the cache object in this case would be too large to handle.

  • πŸ‡«πŸ‡·France mably

    Hi @agentrickard,

    If these were mostly admin links (such as from Admin Toolbar), we could pretty easily exclude those.

    It would definitely bring a nice performance improvement on some of our sites as we make an extensive use of Admin Toolbar and have sometimes more than 400 admin links.

  • πŸ‡ΊπŸ‡ΈUnited States agentrickard Georgia (US)

    I would think we can make that a setting -- or a default behavior if there are no implementations of hook_domain_source_path().

    Probably the best approach is a deny list that is editable, similar to the path settings for blocks.

    We have a model for that in domain_config_ui/src/Form/SettingsForm.php -- a new issue to address that would be ideal.

    ----

    Back to the original issue: two more questions:

    1) What version of Drupal?
    2) What is the memory limit current set to? (You can see this at admin/reports/status) -- and do you have the ability to change it?

  • Hi @agentrickard,

    1) What version of Drupal? - Drupal core 10.1.6

    2) What is the memory limit current set to? - 256M, 512M, 2GB tested, and last time database crash on the server.

    Plus info:

    - Devel module can creat new node.

  • πŸ‡ΊπŸ‡ΈUnited States agentrickard Georgia (US)

    Thanks. So let's go back to the original 3 questions:

    1. If these are all node links, what is it about the site that causes this issue?
    2. Lots of blocks that load all content? Unlimited pagers?
    3. Headless Drupal using JSONAPI to deliver all content?
  • πŸ‡¬πŸ‡§United Kingdom andy_w

    We found the use of fromUserInput and getPathByAlias to be the source of the performance issue, and wondered whether there would be a benefit in making use of some of the other data available in the options, i.e. potentially the entity itself or the href as the first line of defence.

Production build 0.71.5 2024