Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
Red Hat Satellite engineering is moving the tracking of its product development work on Satellite to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "Satellite project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs will be migrated starting at the end of May. If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "Satellite project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/SAT-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 2226567

Summary: Slow "Katello::Applicability::Hosts::BulkGenerate" task when the host has many installed modular packages
Product: Red Hat Satellite Reporter: Hao Chang Yu <hyu>
Component: Errata ManagementAssignee: satellite6-bugs <satellite6-bugs>
Status: CLOSED DUPLICATE QA Contact: Satellite QE Team <sat-qe-bz-list>
Severity: high Docs Contact:
Priority: high    
Version: 6.13.3CC: ahumbe, jlenz, rlavi
Target Milestone: UnspecifiedKeywords: Performance, Regression, Triaged, UserExperience
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-10-20 15:24:29 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 Hao Chang Yu 2023-07-26 01:12:58 UTC
Description of problem:
The calculation of errata applicability takes long time to complete. It will take 5 to 10 minutes to calculate if the host has thousands of installed modular packages.


How reproducible:
Easy

Steps to Reproduce:
1. Prepare a RHEL 8 client and register it to the Satellite.
2. Enable the appstream repository.
3. Enable and install as many module streams as possible.
4. After that force upload the package profile to the Satellite to trigger the  "Katello::Applicability::Hosts::BulkGenerate" task.


Actual results:
~~~
Label: Actions::Katello::Applicability::Hosts::BulkGenerate
Status: stopped
Result: success
...
2: Actions::Katello::Applicability::Hosts::BulkGenerate (success) [ 193.02s / 193.02s ]

Queue: hosts_queue
Started at: 2023-07-05 00:14:14 UTC
Ended at: 2023-07-05 00:17:27 UTC
Real time: 193.02s
Execution time (excluding suspended state): 193.02s
~~~

Expected results:
should at least take second to complete.

Additional info:

We can use the following rake script to test the peformance.
~~~
cat << EOF | foreman-rake console
cf = Host.find(XXXX).content_facet
bound_repos = cf.bound_repositories.collect {|repo| repo.library_instance_id.nil? ? repo.id : repo.library_instance_id}
helper = Katello::Applicability::ApplicableContentHelper.new(cf, ::Katello::Rpm, bound_repos)
helper.fetch_enabled_module_stream_ids.size
Benchmark.measure {p helper.locked_modular_installed_packages(helper.fetch_enabled_module_stream_ids).size}
EOF
~~~

Example output of the rake
~~~
...
helper.fetch_enabled_module_stream_ids.size
442
Benchmark.measure {p helper.locked_modular_installed_packages(helper.fetch_enabled_module_stream_ids).size}
3021
#<Benchmark::Tms:0x0000000014c0e4a0 @label="", @real=114.56473832399934, @cstime=0.0, @cutime=0.0, @stime=0.017389999999998906, @utime=1.518035999999995, @total=1.535425999999994>
~~~