Group permission checking peformance issue after updates

Created on 12 December 2024, about 1 month ago

Problem/Motivation

I am currently debugging a performance issue after updating a large site from Drupal 10.2.x to 10.3.x, which also included updating Group from 2.2.2 to 2.3.1 and removing the variationcache module.

I have found that access checking is a lot more extreme after the updates. Debugging the access checking executions has lead me to a number of files in the group modules where I see functions running many more times since the update.

For instance, inside modules/contrib/group/src/Plugin/Group/RelationHandlerDefault/PermissionProvider.php the getPermission() was called 18 times on a page refresh of /node/add/blog before the update and now after the update it is called 7058 times (testing the same user on both instances).

In all the executions, it gets to elseif ($target === 'entity') and the case is view.

The output of $this->getEntityViewPermission($scope); is the same on both instances for the first 18 times, but after the 18th output, the updated version continues to return 7058 times in total.

Any idea what could be causing such an extreme difference?

Could this be a caching issue or issue with the permission calculator?

Thank You

💬 Support request
Status

Active

Version

2.3

Component

Code

Created by

🇬🇧United Kingdom rick bergmann

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

Comments & Activities

  • Issue created by @rick bergmann
  • 🇧🇪Belgium kristiaanvandeneynde Antwerp, Belgium

    was called 18 times on a page refresh of /node/add/blog before the update and now after the update it is called 7058 times

    Holy crap

    Any idea what could be causing such an extreme difference?
    Could this be a caching issue or issue with the permission calculator?

    Not unless this can be reproduced on a clean install. I have no clue what custom code and/or patches you have running, so either please run xhprof, Blackfire or whatever performance testing tool you're confident using or see if you can reproduce this on a clean install.

    Erring on the side of Major right now as if this is the case for all Group installs, something is really broken.

  • 🇬🇧United Kingdom rick bergmann

    Thank you, I understand. There is a lot of custom code so I would say this is site specifi9c issue, and I have checked on a similar site but was not able to reproduce it there. I will roll back the group update and see if there is any change.

    Profiling shows that the access checking is running on menu items (structured in a large menu) which is loading on the create node pages and group entity access is called in that call stack, so I am trying to understand if these group entity access checks were cached before and at which layer they were cached.

  • 🇧🇪Belgium kristiaanvandeneynde Antwerp, Belgium

    Okay, please keep me posted.

  • 🇬🇧United Kingdom rick bergmann

    I found that the changes from https://www.drupal.org/project/drupal/issues/2463753 🐛 [regression] Do not bypass route access with 'link to any page' permissions for menu links Fixed causes the performance issue.

    I can see that when menuLinkCheckAccess is called it is not returning `$access_result->cachePerPermissions();` any more so the cacheContexts and cacheTags has changed from:

    Drupal\Core\Access\AccessResultAllowed 
      #cacheContexts: array:1 [▼
        0 => "user.permissions"
      ]
      #cacheTags: []
      #cacheMaxAge: -1
    }

    to this:

     Drupal\Core\Access\AccessResultAllowed {
      #cacheContexts: array:3 [▼
        0 => "url.query_args:auHash"
        1 => "user.permissions"
        2 => "languages:language_interface"
      ]
      #cacheTags: array:25 [▼
        0 => "group_content_list:plugin:group_node:blog"
        1 => "group_content_list:plugin:group_node:<content_type_2>"
        3 => "group_content_list:plugin:group_node:<content_type_3>"
        ...
      ]

    There are 23 cacheTag items coming from `group_content_list:plugin:group_node:.

    Not sure if that is expected but seems to cause in issue in my case.

Production build 0.71.5 2024