Problem/Motivation

Installed Drupal version : 10.0.7
PHP version : 8.1.29
SQL : MariaDB 10.6.18

At admin/people, can't show more than 49 users.

Adding users (path admin/people/create) works well until I reach the 50th user. When trying to show the list of (50) users (path admin/people) an error appears on a blank screen. Removing the last added user in the database enables to view the 49 users again.

The logged error is :

Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[42000]: Syntax error or access violation: 1104 <strong>The SELECT would examine more than MAX_JOIN_SIZE rows</strong>; check your WHERE and use SET SQL_BIG_SELECTS=1 or SET MAX_JOIN_SIZE=# if the SELECT is okay: SELECT "u"."entity_id" AS "uid", "u"."roles_target_id" AS "rid" FROM "_SYNuser__roles" "u" WHERE "u"."entity_id" IN ( :uids__0, :uids__1, :uids__2, :uids__3, :uids__4, :uids__5, :uids__6, :uids__7, :uids__8, :uids__9, :uids__10, :uids__11, :uids__12, :uids__13, :uids__14, :uids__15, :uids__16, :uids__17, :uids__18, :uids__19, :uids__20, :uids__21, :uids__22, :uids__23, :uids__24, :uids__25, :uids__26, :uids__27, :uids__28, :uids__29, :uids__30, :uids__31, :uids__32, :uids__33, :uids__34, :uids__35, :uids__36, :uids__37, :uids__38, :uids__39, :uids__40, :uids__41, :uids__42, :uids__43, :uids__44, :uids__45, :uids__46, :uids__47, :uids__48, :uids__49 ) AND "u"."roles_target_id" IN ( :rids__0, :rids__1, :rids__2, :rids__3, :rids__4, :rids__5, :rids__6 ); Array ( [:uids__0] => 104 [:uids__1] => 103 [:uids__2] => 99 [:uids__3] => 98 [:uids__4] => 97 [:uids__5] => 96 [:uids__6] => 95 [:uids__7] => 94 [:uids__8] => 93 [:uids__9] => 92 [:uids__10] => 91 [:uids__11] => 90 [:uids__12] => 89 [:uids__13] => 88 [:uids__14] => 87 [:uids__15] => 86 [:uids__16] => 85 [:uids__17] => 84 [:uids__18] => 83 [:uids__19] => 82 [:uids__20] => 81 [:uids__21] => 80 [:uids__22] => 79 [:uids__23] => 78 [:uids__24] => 77 [:uids__25] => 76 [:uids__26] => 75 [:uids__27] => 74 [:uids__28] => 73 [:uids__29] => 72 [:uids__30] => 71 [:uids__31] => 70 [:uids__32] => 69 [:uids__33] => 68 [:uids__34] => 67 [:uids__35] => 66 [:uids__36] => 65 [:uids__37] => 64 [:uids__38] => 63 [:uids__39] => 62 [:uids__40] => 61 [:uids__41] => 60 [:uids__42] => 59 [:uids__43] => 58 [:uids__44] => 57 [:uids__45] => 56 [:uids__46] => 55 [:uids__47] => 4 [:uids__48] => 3 [:uids__49] => 2 [:rids__0] => anonymous [:rids__1] => authenticated [:rids__2] => content_editor [:rids__3] => administrator [:rids__4] => huurder [:rids__5] => gast [:rids__6] => eigenaar ) in Drupal\user\Plugin\views\field\Roles->preRender() (line 77 of /customers/9/8/9/vmeastrid.be/httpd.www/syn/core/modules/user/src/Plugin/views/field/Roles.php).

Is this a problem to be solved by the host provider or do I need to add SET SQL_BIG_SELECTS=1 or SET MAX_JOIN_SIZE=# ?

Steps to reproduce

TBA

Proposed resolution

TBD

Remaining tasks

Does this happen on currently supported versions of Drupal.
Steps to reproduce

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

CommentFileSizeAuthor
#2 Screenshot 2024-07-09 at 11.42.03 PM.png997.09 KBjava008

Comments

iCU created an issue. See original summary.

java008’s picture

StatusFileSize
new997.09 KB

Tried to reproduce the same issue in Local Drupal 10. There is no issue for me. Refer below screenshot.

mradcliffe’s picture

Project: Drupal.org /community section » Drupal core
Version: » 10.0.x-dev
Component: Community Content » user.module
Category: Bug report » Support request
Issue tags: -Novice

Hi @iCU, @java008, the drupal.org community section project is a project specifically for the Community section on drupal.org, and not for general support for Drupal core. I am moving this into the core project as a support request. note that Drupal 10.0.0 is out-of-date and you should update to the latest Drupal 10 minor release for security reasons.

I am removing the Novice tag from this issue because this is a support request and the Novice tag is used by Drupal core mentors to tag issues that have a clear task and resolution.

I’m using this documentation as a source: https://www.drupal.org/community/contributor-guide/task/triage-novice-is...

cilefen’s picture

Have you modified the default view?

cilefen’s picture

Version: 10.0.x-dev » 11.x-dev
Status: Active » Postponed (maintainer needs more info)
petrsocha’s picture

Adjusting the settings.php fixes the issue:

$databases['default']['default'] = array (
...
'init_commands' => [
'big_selects' => 'SET SQL_BIG_SELECTS=1',
],
'pdo' => [
PDO::ATTR_TIMEOUT => 5,
],
);

But since 50 users isn't really a big select, I suppose the database query is not very well formed.

tma0’s picture

Seems it is about some mysql settings. The same code I see in github for D11 so likely persists (https://github.com/drupal/drupal/blob/11.x/core/modules/user/src/Plugin/...). The error is misleading and fix is avoiding multiple IN conditions generating large sets. Even subquery does not help. But INNER JOIN furtunately works:

    if ($uids) {
      $roles = user_roles();
      $result = $this->database->query('SELECT DISTINCT [u1].[entity_id] AS [uid], [u1].[roles_target_id] AS [rid] FROM 
        (SELECT [entity_id], [roles_target_id] FROM {user__roles} WHERE [entity_id] IN ( :uids[] )) [u1],
        (SELECT [entity_id], [roles_target_id] FROM {user__roles} WHERE [roles_target_id] IN ( :rids[] )) [u2]
        WHERE [u1].[entity_id] = [u2].[entity_id]', [':uids[]' => $uids, ':rids[]' => array_keys($roles)]);
      // fix: SQLSTATE[42000]: Syntax error or access violation: 1104 The SELECT would examine more than MAX_JOIN_SIZE rows; check your WHERE and use SET SQL_BIG_SELECTS=1 or SET MAX_JOIN_SIZE=# if the SELECT is okay
      // {user__roles} [u] WHERE [u].[entity_id] IN ( :uids[] ) AND [u].[roles_target_id] IN ( :rids[] )', [':uids[]' => $uids, ':rids[]' => array_keys($roles)]);
nicxvan’s picture

Also which modules do you have installed?

tma0’s picture

How to get list of installed modules in raw list (beyond drush) ?
But related code is in core module. I have 2020 users, 5 roles in DB. I have no control on mysql as it is on hosting. I can reproduce in phpmyadmin as raw query and it always happens when "SELECT FROM WHERE IN () AND IN ()" or "SELECT FROM WHERE IN () SELECT FROM IN()" command is raised. Likely mysql does an UNION or so. INNER JOIN works well.

khoebeke’s picture

I have the same issue, I have +/-160 users on my website, I can test some things if you want

smustgrave’s picture

I'm personally not able to replicate with a base drupal install. Could it be a DB setting perhaps?

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.

quietone’s picture

Category: Support request » Bug report
Issue summary: View changes
Issue tags: +Bug Smash Initiative

It is not clear to me why this was changed to a Support Request, so restoring the Bug Report category. I could be wrong.

This still needs more information.

Does this happen on a currently supported version of Drupal?
This needs steps to reproduce the issue starting from "Install Drupal core". Being able to reproduce the problem will allow the community to write tests.

Thanks.

danielveza’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)

It's been over a year since @smustgrave could not replicate this, and 4 months since @quietone asked for more information. Since we haven't had any other reports, I'm going to mark this one as closed. Thanks all!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.