Bug 1583894 - Add remove orphan dynflow task in foreman_tasks:cleanup script.
Summary: Add remove orphan dynflow task in foreman_tasks:cleanup script.
Keywords:
Status: CLOSED DUPLICATE of bug 1557067
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: Tasks Plugin
Version: 6.3.1
Hardware: Unspecified
OS: Linux
unspecified
high
Target Milestone: Unspecified
Assignee: satellite6-bugs
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2018-05-30 02:16 UTC by Hao Chang Yu
Modified: 2021-09-09 14:17 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2018-05-30 07:27:02 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Knowledge Base (Solution) 2755731 0 None None None 2018-05-30 02:25:02 UTC

Description Hao Chang Yu 2018-05-30 02:16:48 UTC
Description of problem:
Due to the previous misunderstanding, users were deleting the foreman tasks directly from the foreman-rake console using ".destroy" function. This has cause huge performance impact to the Satellite when the orphan dynflow tasks are accumulated to thousands.

I had seen 5 or 6 cases that Satellite suffering from dynflow performance issue due to this issue and I believe there will be more. This is the reason that I decide to file this bug.

High unfinished orphan dynflow tasks usually cause the following issues.
- Host registration timeout.
- Very slow content view publish. Running for a day or more.


In the private note of KCS "https://access.redhat.com/solutions/2755731" has suggested a way to clean up the orphan dynflow tasks. I would like to suggest to add this code into the foreman task clean up script so that the orphan tasks clean up can be run in the cron job. This will prevent a lot of cases to be opened and will automatically fix performance issue for a lot of users.

-----------------
batch_size = 1000
persistence = ForemanTasks.dynflow.world.persistence
adapter = persistence.adapter
plans_without_tasks = adapter.db.fetch("select dynflow_execution_plans.uuid from dynflow_execution_plans left join foreman_tasks_tasks on (dynflow_execution_plans.uuid = foreman_tasks_tasks.external_id) where foreman_tasks_tasks.id IS NULL")
deleted = 0
total = plans_without_tasks.count
plans_without_tasks.all.map{|x| x[:uuid]}.in_groups_of(batch_size, false).each do |uuids|
  delete_count = persistence.delete_execution_plans({ 'uuid' => uuids }, batch_size)
  deleted += delete_count
  puts "deleted #{deleted} out of #{total}"
end
----------------

The performance issue is fixed after deleting the orphan dynflow tasks, such as host registration was previously timeout will finish in seconds.

Comment 1 Adam Ruzicka 2018-05-30 07:27:02 UTC

*** This bug has been marked as a duplicate of bug 1557067 ***


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