Bug 2226567 - Slow "Katello::Applicability::Hosts::BulkGenerate" task when the host has many installed modular packages
Summary: Slow "Katello::Applicability::Hosts::BulkGenerate" task when the host has man...
Keywords:
Status: NEW
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: Errata Management
Version: 6.13.3
Hardware: Unspecified
OS: Unspecified
high
high
Target Milestone: Unspecified
Assignee: satellite6-bugs
QA Contact: Satellite QE Team
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2023-07-26 01:12 UTC by Hao Chang Yu
Modified: 2023-08-16 00:20 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed:
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

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>
~~~


Note You need to log in before you can comment on or make changes to this bug.