Bug 1985101

Summary: Authorization generates inefficient SQL query for taxonomy-overriden permissions
Product: Red Hat Satellite Reporter: Pablo Hess <phess>
Component: Users & RolesAssignee: satellite6-bugs <satellite6-bugs>
Status: CLOSED WONTFIX QA Contact: Danny Synk <dsynk>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.8.0CC: afeferku, apatel, aruzicka, jjansky, kgaikwad, lstejska, mhulan, momran, oezr
Target Milestone: UnspecifiedKeywords: Performance, Triaged
Target Release: Unused   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2024-02-07 18:16:21 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Pablo Hess 2021-07-22 20:52:30 UTC
Description of problem:
Job execution lookups prior to firing off a new job was suddenly very slow, taking upwards of 5 minutes to instantiate a single job execution.
After creating a new index on the foreman database, job execution instantiation went back to the usual duration of 3 seconds.

The index was created on the taxable_taxonomies table with the command below:

  create unique index taxable_id_id on taxable_taxonomies (taxable_id, id);


Version-Release number of selected component (if applicable):
satellite-6.8.5-1.el7sat.noarch


How reproducible:
100% of times when invoking a new job.

Steps to Reproduce:
1. Invoke new job on the web UI or through hammer.

Actual results:
Takes upwards of 5 minutes to create the job.

Expected results:
Few seconds to create the job.

Additional info:
The new index was created after examining the SQL queries being run by foreman while invoking the job. The new DB index changed the job template lookup significantly: the sql query now avoids nested loops and does merge joins and hashed joins instead.

Comment 9 Tomer Brisker 2021-10-21 14:43:38 UTC
Created redmine issue https://projects.theforeman.org/issues/33763 from this bug

Comment 10 Pablo Hess 2021-10-26 19:17:11 UTC
This issue was found again on a live Satellite 6.9.

Condition to trigger the problem: having permission filters customized to apply to an individual org or location only. The Satellite in question had many such permission filters and the slow lookup that did countless inner joins against taxable_taxonomies was being logged to take 700+ seconds.

By adding the index to the foreman db on postgres as below, the same lookup was able to complete in under 500 ms so it's not logged anymore.

    create index idx_taxable_id on taxable_taxonomies (taxable_id);


Thanks tbrisker++ for the significant assistance in identifying and characterizing this issue.

Comment 14 Brad Buckingham 2024-01-09 20:58:59 UTC
Upon review of our valid but aging backlog the Satellite Team has concluded that this Bugzilla does not meet the criteria for a resolution in the near term, and are planning to close in a month. This message may be a repeat of a previous update and the bug is again being considered to be closed. If you have any concerns about this, please contact your Red Hat Account team.  Thank you.

Comment 15 Brad Buckingham 2024-02-07 18:16:21 UTC
Thank you for your interest in Red Hat Satellite. We have evaluated this request, and while we recognize that it is a valid request, we do not expect this to be implemented in the product in the foreseeable future. This is due to other priorities for the product, and not a reflection on the request itself. We are therefore closing this out as WONTFIX. If you have any concerns about this feel free to contact your Red Hat Account Team. Thank you.