Bug #39585
openHost - Available Errata report generation consumes too much memory
Description
When generating the Host - Available Errata report, the template loops over each host and runs `host.applicable_errata.includes(:cves).search_for(filter)`, so we're essentially loading every host's available errata as an individual query. Since there is no deduplication, the database needs to allocate RAM for N hosts x N errata per host x N CVEs AND we are hitting the limit for query size in postgres. Please see the JIRA for actual reproducers.
The fix is to drop iteration over hosts as a part of the lookup and move that logic to inside the ActiveRecord queries. Hosts should have the same errata in a lot of cases, so it would solve the request size limit issue if we deduplicate by id as well. We should be able to join host content_facet_ids with Katello::Erratum and solve this with a few queries.
Related to: https://projects.theforeman.org/issues/39586
Updated by The Foreman Bot 4 days ago
- Status changed from New to Ready For Testing
- Pull request https://github.com/Katello/katello/pull/11817 added
Updated by Ian Ballou 2 days ago
- Difficulty set to hard
- Triaged changed from No to Yes