Bug 1614063

Summary: Improve MonitorEventQueue performance for large workloads
Product: Red Hat Satellite Reporter: Mike McCune <mmccune>
Component: Content ManagementAssignee: Justin Sherrill <jsherril>
Status: CLOSED ERRATA QA Contact: sbadhwar
Severity: high Docs Contact:
Priority: unspecified    
Version: 6.3.2CC: andrew.schofield, jdickers, pmoravec, pm-sat, sbadhwar, zhunting
Target Milestone: 6.4.0Keywords: PrioBumpField, Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: tfm-rubygem-katello-3.7.0.14-1 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1622206 (view as bug list) Environment:
Last Closed: 2018-10-16 19:04:30 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 Mike McCune 2018-08-08 22:35:42 UTC
On systems with large numbers of registered hosts (20-50,000) there are cases when synchronization events may trigger large volume of entries landing in the katello_events table (40,000+ rows).

The majority of these rows are import_host_applicability events that need to be processed. This processing can often take hours and sometimes an entire day.

Due to load induced in processing all these events, there are times when foreman-tasks gets overloaded and may stop processing entirely and the queue ceases to drain.

We need to optimize the processing time of this queue of events to ensure they can be worked through in a faster manner than is being done now.

Some analysis has taken place that shows that a good portion of the work going through the katello_events table entries is SELECTS/INSERTS/UPDATES to the dynflow_steps table which can often take 100-300ms or more. We may update the routine to reduce this and perform other changes to make this task perform better.

Comment 2 Justin Sherrill 2018-08-09 20:19:03 UTC
Created redmine issue https://projects.theforeman.org/issues/24576 from this bug

Comment 3 Satellite Program 2018-08-09 22:10:21 UTC
Upstream bug assigned to jsherril

Comment 4 Satellite Program 2018-08-09 22:10:24 UTC
Upstream bug assigned to jsherril

Comment 6 Satellite Program 2018-08-20 16:10:45 UTC
Moving this bug to POST for triage into Satellite 6 since the upstream issue https://projects.theforeman.org/issues/24576 has been resolved.

Comment 11 Mike McCune 2018-09-11 14:59:37 UTC
To test a large amount of data for the MonitorEventQueue to process you can do the following:

1) Load data to be processed by the queue:

# foreman-rake console

> 1.times { Katello::Host::ContentFacet.pluck(:host_id).each { |id|::Katello::EventQueue.push_event(::Katello::Events::ImportHostApplicability::EVENT_TYPE, id)}  }

Once this completes, monitor progress in the UI on the task details, it will indicate the # of rows processed

2) You can also monitor the count in the database:

# sudo -u postgres psql -d foreman -c 'select count(*) from katello_events;'  

 count 
-------
  9331
(1 row)

Once that reaches 0 the processing is complete.  

We measured between 30-40% speed improvements in processing items in this queue before this bugfix and after.

Comment 13 Mike McCune 2018-09-20 20:12:48 UTC
*** Bug 1622206 has been marked as a duplicate of this bug. ***

Comment 14 Bryan Kearney 2018-10-16 19:04:30 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2018:2927