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

PHP Fatal error: Allowed memory size of 2147483648 bytes exhausted (tried to allocate 20480 bytes) in /core/lib/Drupal/Core/Cache/DatabaseBackend.php on line 172'

PHP Fatal error: Allowed memory size of 2147483648 bytes exhausted (tried to allocate 20480 bytes) in /core/lib/Drupal/Core/Cache/Cache.php on line 30'

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.

CommentFileSizeAuthor
#16 domain-source.patch1.14 KBandy_w

Issue fork domain-3402534

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

intradavid created an issue. See original summary.

intradavid’s picture

Issue summary: View changes
intradavid’s picture

Issue summary: View changes
mably’s picture

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 ;)

intradavid’s picture

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

path_alias = 291,340

mably’s picture

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

As I said above, we are displaying something like 1150 links on our home page and the request already takes about 100MB of memory...

Have you tried reducing the number of links displayed? Increase the available memory?

intradavid’s picture

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.

+ If i want to add node same.

PHP Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 16384 bytes) in /core/lib/Drupal/Core/Database/StatementWrapperIterator.php on line 110; PHP message: PHP Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 20480 bytes) in /core/modules/mysql/src/Driver/Database/mysql/ExceptionHandler.php on line 46; 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: /node/add

intradavid’s picture

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

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

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

mably’s picture

@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.

intradavid’s picture

mably, How can I help you solve this?

agentrickard’s picture

Priority: Critical » Major
Status: Needs review » Active

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.

mably’s picture

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.

agentrickard’s picture

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?

intradavid’s picture

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.

agentrickard’s picture

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?
andy_w’s picture

StatusFileSize
new1.14 KB

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.

mably’s picture

Status: Active » Needs work

Looks like the MR needs a rebase.

mably’s picture

Status: Needs work » Closed (duplicate)
Related issues: +#3232343: DomainSourcePathProcessor is resource intensive

I will close this issue in favor of issue #3232343: DomainSourcePathProcessor is resource intensive.

In my point of view, the current best solution in this case is probably to apply the patch from Core issue #3202329 and then either the corresponding patch from issue #3232343 or MR 177 from issue #3271978.

They both implement some of the improvements suggested in this thread.