Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Indexes lacking in securitygroups_acl_roles #10539

Open
SinergiaCRM opened this issue Oct 4, 2024 · 0 comments
Open

Indexes lacking in securitygroups_acl_roles #10539

SinergiaCRM opened this issue Oct 4, 2024 · 0 comments
Labels
Area: Databases Issues & PRs related to all things regarding databases Priority:Important Issues & PRs that are important; broken functions, errors - there are workarounds Severity: Moderate Key function failed, but no or little impact Status:Fix Proposed A issue that has a PR related to it that provides a possible resolution Type: Bug Bugs within the core SuiteCRM codebase

Comments

@SinergiaCRM
Copy link
Contributor

Issue

The table securitygroups_acl_roles wich relates security groups with roles only has the primary index but not the needed index to query the roles assigned to a security group.
In situations where a lot of SGs exist this can cause a problem due to the excessive time wated by the query.

Possible Fix

Include the index definition via vardefs

Steps to Reproduce the Issue

1.Define a lot of Security groups (we have more than 500) with one or more roles assigned to each one
2.Define some users and assign to them some of the created groups
3.Make concurrent logins (we had more than 20 users trying to login at the same time)
4.Execute a SHOW FULL PROCESSLIST and observe that a query similar to the following one is getting stuck:
`(SELECT acl_actions .*, acl_roles_actions.access_override, 1 as user_role
FROM acl_actions
INNER JOIN acl_roles_users ON acl_roles_users.user_id =
'dfce34bb-a134-3b87-66c8-665db32ee072' AND acl_roles_users.deleted = 0
LEFT JOIN acl_roles_actions ON acl_roles_actions.role_id =
acl_roles_users.role_id AND acl_roles_actions.action_id = acl_actions.id AND
acl_roles_actions.deleted=0
WHERE acl_actions.deleted=0 )
UNION
(SELECT acl_actions .*, acl_roles_actions.access_override, 0 as
user_role
 FROM acl_actions
INNER JOIN securitygroups_users ON securitygroups_users.user_id
 = 'dfce34bb-a134-3b87-66c8-665db32ee072' AND securitygroups_users.deleted = 0
 INNER JOIN securitygroups_acl_roles ON
securitygroups_users.securitygroup_id = securitygroups_acl_roles.securitygroup_id and
securitygroups_acl_roles.deleted = 0
LEFT JOIN acl_roles_actions ON acl_roles_actions.role_id =
securitygroups_acl_roles.role_id AND acl_roles_actions.action_id = acl_actions.id AND
acl_roles_actions.deleted=0
WHERE acl_actions.deleted=0 )
UNION
(SELECT acl_actions.*, 0 as access_override, -1 as user_role
FROM acl_actions
WHERE acl_actions.deleted = 0 )
ORDER BY user_role desc, category,name,access_override desc`

Context

Those query getting stuck made that some user could not login until some minutes passed.

Version

7.12.12

What browser are you currently using?

Chrome

Browser Version

No response

Environment Information

MAriaDB, PHP 7.4

Operating System and Version

Debian

@SinergiaCRM SinergiaCRM added the Type: Bug Bugs within the core SuiteCRM codebase label Oct 4, 2024
enricsinergia pushed a commit to SinergiaTIC/SuiteCRM that referenced this issue Oct 4, 2024
@johnM2401 johnM2401 added Priority:Important Issues & PRs that are important; broken functions, errors - there are workarounds Area: Databases Issues & PRs related to all things regarding databases Severity: Moderate Key function failed, but no or little impact Status:Fix Proposed A issue that has a PR related to it that provides a possible resolution labels Oct 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Databases Issues & PRs related to all things regarding databases Priority:Important Issues & PRs that are important; broken functions, errors - there are workarounds Severity: Moderate Key function failed, but no or little impact Status:Fix Proposed A issue that has a PR related to it that provides a possible resolution Type: Bug Bugs within the core SuiteCRM codebase
Projects
None yet
Development

No branches or pull requests

2 participants