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 2280509

Summary: Pulp never purge the completed tasks
Product: Red Hat Satellite Reporter: Hao Chang Yu <hyu>
Component: RepositoriesAssignee: Ian Ballou <iballou>
Status: CLOSED MIGRATED QA Contact: Satellite QE Team <sat-qe-bz-list>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.15.0CC: dalley, dkliban, ggainey, iballou, jpasqual, mdellweg, rchan, rlavi
Target Milestone: UnspecifiedKeywords: MigratedToJIRA, Performance, Triaged, WorkAround
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: 2024-06-06 17:39:10 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 2024-05-15 01:30:39 UTC
Description of problem:
The completed Pulp tasks stay forever and never be purged by Pulp. For a busy Satellite environment, the number of completed tasks can easily reach millions of records.

Large tasks table may cause the following issues:

1. Large core_task table size (more than 10GB)
2. Affecting Pulp performance related to pulp task queries.


For example. we can see the following slow queries of core_task table in the database logs.
~~~
duration: 5173.306 ms  statement: SELECT 1 AS "a" FROM "core_task" WHERE ("core_task"."pulp_created" < 'xxxxxxxxxxxxx'::timestamptz AND "core_task"."state" IN ('waiting', 'running', 'canceling') AND "core_task"."reserved_resources_record" && (ARRAY['/pulp/api/v3/domains/xxxxxxxxxxxxxxxxxxxxxxxxxxxx/', '/api/v3/distributions/', 'shared:/api/v3/distributions/'])::text[]) LIMIT 1

duration: 6680.679 ms  statement: SELECT 1 AS "a" FROM "core_task" WHERE ("core_task"."pulp_created" < 'xxxxxxxxxxxxx'::timestamptz AND "core_task"."state" IN ('waiting', 'running', 'canceling') AND "core_task"."reserved_resources_record" && (ARRAY['/pulp/api/v3/domains/xxxxxxxxxxxxxxxxxxxxxxxxxxxx/', '/api/v3/distributions/', 'shared:/api/v3/distributions/'])::text[]) LIMIT 1
~~~

Additional info:
The workaround to use pulp command to purge the tasks.

E.g. the below command will purge the completed tasks older than 2 weeks.
~~~
pulp --force task purge --finished-before $(date --date="$(date) -2 week"  +%Y-%m-%d) --state completed --state failed --state canceled
~~~

Comment 1 Daniel Alley 2024-05-15 02:18:15 UTC
Pulp already provides an API for purging tasks, but like orphan cleanup, calling it occasionally is up to the admin rather than something Pulp triggers automatically.  

I'm not sure what the correct component is for this though.

Comment 4 Ian Ballou 2024-05-28 18:44:59 UTC
Based on https://github.com/pulp/pulpcore/pull/5379/files, we now need to set the TASK_PROTECTION_TIME setting to enable automated task cleanup in Pulp.

I'm changing the component to "Installation".

It's noted that the issue is fixed in Pulpcore 3.54, so we'll either need to request a backport to Pulpcore 3.49 or wait another release to pick it up.

If needed in the short term, Katello could call the task purge API during orphan cleanup, but then the work to automate it in Pulpcore wouldn't be taken advantage of.

Moving back to NEW since the component has now changed to Installer.

Comment 11 Ian Ballou 2024-05-30 18:42:14 UTC
Created redmine issue https://projects.theforeman.org/issues/37521 from this bug

Comment 12 Eric Helms 2024-06-06 17:39:10 UTC
This BZ has been automatically migrated to the issues.redhat.com Red Hat Issue Tracker. All future work related to this report will be managed there.

Due to differences in account names between systems, some fields were not replicated.  Be sure to add yourself to Jira issue's "Watchers" field to continue receiving updates and add others to the "Need Info From" field to continue requesting information.

To find the migrated issue, look in the "Links" section for a direct link to the new issue location. The issue key will have an icon of 2 footprints next to it, and begin with "SAT-" followed by an integer.  You can also find this issue by visiting https://issues.redhat.com/issues/?jql= and searching the "Bugzilla Bug" field for this BZ's number, e.g. a search like:

"Bugzilla Bug" = 1234567

In the event you have trouble locating or viewing this issue, you can file an issue by sending mail to rh-issues. You can also visit https://access.redhat.com/articles/7032570 for general account information.