As per kristiaanvandeneynde's request to raise a support request related to #2796197: Group or Group Node generates some massive queries, I've spent a lot of time getting down to a repeatable situation for my issues...
I have a site with ~500 groups of one group type. I have ~6000 content items in them, all of the same content type. There are no group content type fields.
The environment:
All members of a group have the permissions to add nodes to the group.
All outsiders and anonymous visitors have permissions to view groups and view the content of groups.
Visiting a group page (pathauto alias, working just fine), shows the group and a block view listing the content in that group. Paged, 24 items to a page
There is a sidebar block showing the content of the group via a $entities = $group->getContentEntities('group_node:travel_story_update'); (though disabling this block makes no difference to the issue)
The outcome:
When a user clicks to add a new node, the form displays correctly and, upon filling and clicking submit, there is a long delay, several seconds (maybe up to 10s) before the second form in the wizard is displayed.
After clicking the second form submit, either another very long delay (>10s) or the site reports and out of memory error, even with 300MB allocated!
I'm very happy to add as much detail to this as is needed - I'm getting a bit desperate to find out what on earth is going on here now. I'm really confused by it, to be honest.
| Comment | File | Size | Author |
|---|---|---|---|
| #15 | group-n2837069-15.patch | 763 bytes | damienmckenna |
| #15 | group-n2837069-15.interdiff.txt | 1.02 KB | damienmckenna |
Comments
Comment #2
rachel_norfolkOh - and I should mention that this issue still happens to non-admin uses that have the "Bypass group access control" permission
Comment #3
rachel_norfolkRight - and more debug info:
With web profiler enabled and user set to have "Bypass group access control" permission, I placed a breakpoint inside the condition in
And, after submitting the first node wizard form, I come across the breakpoint 6 times before the page renders, giving the attached output to web profiler.
After submitting the second part of the wizard, I came across the breakpoint 10 times before the page renders, giving the attached second output to web profiler.
Now, I'm actually seeing php out of memory errors, even after increasing memory for php to 300M. That huge select query in the first web profiler would lend me to think that ALL nodes are still being checked for access somehow, giving the huge IN clause. (there are ~ 6000 nodes in groups altogether - just a few dozen in the group I am adding to)
Is there anything else I can obtain?
Comment #4
damienmckennaSounds like a performance issue, which is a bug and at this rate seems to be a major one.
Comment #5
rachel_norfolkIs there *anything* else I can get that would help determine what's going on?
Comment #6
damienmckennaI don't know the module well enough to be able to help debug the problems, sorry.
Comment #7
rachel_norfolkMore digging because I really want to get info to make it possible to resolve this...
So, out of memory appears to happen in
And what it is doing there is unserialising nodes. Annoyingly, it is unserialising nodes that are NOT part of the group this node is being added to!!
$cache on one example (I had a conditional breakpoint set there when memory usage was very large (thanks jp_stacey). And that breakpoint is hit for lots and lots and lots of nodes - this being the first.
That sounds interesting to me...
Comment #8
rachel_norfolkComment #9
rachel_norfolkI can hardly believe that I have found what appears to have been causing the issue.
Early on in the build, I set up the group_content type for the group and, in Manage Form Display, I set the Content field to be a Select list. I really didn't think any more about this.
It seems that, even though the group content form isn't really displayed as such, especially the Content field, Drupal *does* attempt to create the list as the group_content entity is created. This leads to a load of ALL eligible content entities and, eventually, an exhaustion of php memory.
Simply changing the Content field back to the default of autocomplete has transformed the site back into a nice speedy, lean one.
So, my actual issue is "resolved" but we need to find a way of preventing others falling into this trap. A form_alter to prevent the widget being changed, perhaps?
Comment #10
rachel_norfolkSo, it seems to me that we always need to ensure that people do not use the options_select widget on group_content forms (even if the form isn't actually used as such!!)
Here's a patch. Best way I can think of doing it. I'm off for a bit of fresh air cos this has *really* flummoxed me for days...
Comment #11
rachel_norfolkOne day, I'll actually remember to set an issue to Needs Review first time around!
Comment #12
damienmckennaHow about instead of blocking what could be a useful UI for some sites, instead provide a warning to not use the selector if there are a lot of referenceable entities? At the very least the unset() line needs its indenting fixed.
Comment #13
rachel_norfolkI can live with that as a suggestion - would adding text to the option be sufficient, do you think?
Comment #14
rachel_norfolkHow about this?
Comment #15
damienmckennaThat's good. Here's a small tweak.
Comment #16
damienmckennaOne question I have - should there be a check to make sure the field the correct type, so the string definition only happens when dealing with a group field?
Comment #17
rachel_norfolkThe field can only be of one type as it is created by the group module. We already check it is a group-generated form.
Comment #18
kristiaanvandeneyndeSorry, I'm just catching up after a long sick leave/vacation. This one had me laughing out loud:
Reading further through the thread now, but I thought I would share that :D
P.S.: Good catch!
Comment #19
rachel_norfolkYou can imagine the words that came out of my potty mouth when I worked out what was going on!!! :-D
Seems a good thing to dissuade others from doing!
P.S. Glad to have you back
Comment #20
kristiaanvandeneyndeRight so having read up on this, I can see the issue and yet I am not sure if it's up to us to patch this. This memory issue applies to any entity reference field on any site that has a lot of content.
So while I am impressed by the way rachel_norfolk investigated this and grateful to DamienMcKenna for pitching in, I'd argue that this is something that could be addressed in core instead.
A few possible solutions that aren't mutually exclusive:
What do you think? If we decide to not take action here, I'm still very willing to assign an issue credit to both of you for the excellent progress made here.
Comment #21
damienmckennaAll props are due to rachel_norfolk for digging through this.
Comment #22
kristiaanvandeneyndeRespectfully, closing as "works as designed" because there isn't actually anything wrong with Group here. Marking as "Fixed", though, to reward the both of you an issue credit. (The system should allow me to reward one regardless of Fixed status IMO)
Comment #23
rachel_norfolkI can live with that :-)