Bug 720533 - Satellite 5.4: erratamailer_fill_work_queue causes high CPU usage
Summary: Satellite 5.4: erratamailer_fill_work_queue causes high CPU usage
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Satellite 5
Classification: Red Hat
Component: Server
Version: 540
Hardware: All
OS: Linux
high
high
Target Milestone: ---
Assignee: Jan Pazdziora
QA Contact: Martin Minar
URL:
Whiteboard:
Depends On:
Blocks: sat54-blockers
TreeView+ depends on / blocked
 
Reported: 2011-07-12 00:59 UTC by Xixi
Modified: 2018-12-03 17:19 UTC (History)
6 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2011-08-16 13:57:33 UTC
Target Upstream Version:


Attachments (Terms of Use)
explain plan output before patch (12.73 KB, text/plain)
2011-07-12 22:08 UTC, Xixi
no flags Details
explain plan output after patch (16.85 KB, text/plain)
2011-07-12 22:11 UTC, Xixi
no flags Details
patch (3.29 KB, patch)
2011-07-12 23:43 UTC, Xixi
no flags Details | Diff


Links
System ID Private Priority Status Summary Last Updated
Red Hat Bugzilla 701457 1 None None None 2021-01-20 06:05:38 UTC
Red Hat Product Errata RHBA-2011:1162 0 normal SHIPPED_LIVE Red Hat Network Satellite Server spacewalk-java bug fix update 2011-08-16 13:56:28 UTC

Internal Links: 701457

Description Xixi 2011-07-12 00:59:58 UTC
Description of problem:
This is a spin-off from Bug 701457.  After applying hotfix packages, there is still another query that's resulting in high CPU consumption by Oracle.

top - 10:35:25 up 133 days, 22:22, 2 users, load average: 1.35, 1.14, 1.09 Tasks: 304 total, 2 running, 302 sleeping, 0 stopped, 0 zombie Cpu(s): 14.3%us, 0.2%sy, 0.0%ni, 85.0%id, 0.3%wa, 0.0%hi, 0.1%si, 0.0%st Mem: 37037420k total, 33964124k used, 3073296k free, 425924k buffers Swap: 37736676k total, 268344k used, 37468332k free, 31141524k cached PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 32322 oracle 25 0 5898m 1.1g 1.0g R 99.8 3.2 90:18.50 oracle TEXT ---------------------------------------------------------------- INSERT INTO rhnPaidErrataTempCache (user_id, server_id, errata_id) SELECT urn.user_id, snv.server_id, snv.errata_id FROM rhnServerNeededView snv JOIN rhnUserReceiveNotifications urn ON snv.server_id = urn.server_id JOIN rhnServerChannel sc ON sc.server_id = snv.server_id JOIN rhnServer S ON S.id = SC.server_id WHERE sc.channel_id = :1 AND snv.errata_id = :2 AND S.org_id = :3

... which appears to be "erratamailer_fill_work_queue" query in src/com/redhat/rhn/common/db/datasource/xml/Task_queries.xml -
...
<write-mode name="erratamailer_fill_work_queue">
   <query params="errata_id,org_id, channel_id">
  INSERT INTO rhnPaidErrataTempCache
    (user_id, server_id, errata_id)
    SELECT urn.user_id, snv.server_id, snv.errata_id
      FROM rhnServerNeededView snv
      JOIN rhnUserReceiveNotifications urn
        ON snv.server_id = urn.server_id
      JOIN rhnServerChannel sc
        ON sc.server_id = snv.server_id
      JOIN rhnServer S
        ON S.id = SC.server_id
     WHERE sc.channel_id = :channel_id
       AND snv.errata_id = :errata_id
       AND S.org_id = :org_id
   </query>
</write-mode>
...

...which is called by src/com/redhat/rhn/taskomatic/task/ErrataMailer.java in populateWorkQueue(Long errataId, Long orgId, Long channelId).  Basically this is the task that works on processing/sending out notifications for errata.

Version-Release number of selected component (if applicable):
Red Hat Network (RHN) Satellite 5.4.0

How reproducible:
Always.

Steps to Reproduce:
1. A large Satellite deployment, e.g., with >30K clients registered (import customer db)
2. Run the SQL above and/or watch taskomatic cpu consumption

Actual results:
SQL is too slow (1.5 hrs at least according to customer / Oracle high load

Expected results:
SQL runs as expected / Oracle does not consume high cpu

Additional Information:

Comment 4 Xixi 2011-07-12 22:08:00 UTC
Created attachment 512531 [details]
explain plan output before patch

Comment 5 Xixi 2011-07-12 22:11:59 UTC
Created attachment 512532 [details]
explain plan output after patch

Comment 6 Xixi 2011-07-12 23:43:09 UTC
Created attachment 512540 [details]
patch

Comment 10 Jan Pazdziora 2011-07-13 07:44:38 UTC
Fixed in Spacewalk master, 438f6e1820ae9ce7fad8529c484ce4b6bebabacd. In Spacewalk master it's erratamailer_get_relevant_servers.

We replace rhnServerNeededView with custom subselect which is generally equivalent.

Comment 27 errata-xmlrpc 2011-08-16 13:57:33 UTC
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHBA-2011-1162.html


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