Bug 1585890

Summary: foreman-rake foreman_tasks:cleanup does not remove tasks from foreman_tasks_locks table
Product: Red Hat Satellite Reporter: Ram Nainsingh Tiruwa <ramsingh>
Component: Tasks PluginAssignee: Ivan Necas <inecas>
Status: CLOSED ERRATA QA Contact: Kedar Bidarkar <kbidarka>
Severity: medium Docs Contact:
Priority: medium    
Version: 6.3.1CC: andrew.schofield, aruzicka, hyu, inecas, kbidarka, mmccune, pcreech
Target Milestone: UnspecifiedKeywords: Triaged
Target Release: Unused   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: tfm-rubygem-foreman-tasks-0.9.6.5-1 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1596358 (view as bug list) Environment:
Last Closed: 2018-08-22 20:07:12 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 Ram Nainsingh Tiruwa 2018-06-05 02:27:45 UTC
#foreman-rake foreman_tasks:cleanup does not remove tasks from foreman_tasks_locks table

Red Hat Satellite 6.3.1

#su - postgres -c "psql foreman -c 'select * from foreman_tasks_tasks'" |wc -l
19

#su - postgres -c "psql foreman -c 'select * from foreman_tasks_locks'"|wc -l
1125

#foreman-rake foreman_tasks:cleanup TASK_SEARCH="" AFTER=1d

After executing the cleanup script, below is the status of the tasks:

su - postgres -c "psql foreman -c 'select * from foreman_tasks_tasks'" |wc -l
17

su - postgres -c "psql foreman -c 'select * from foreman_tasks_locks'"|wc -l
1125

Expectation to delete old task from foreman_tasks_locks table.

Comment 1 Hao Chang Yu 2018-06-05 02:35:16 UTC
The following upstream commit has added a "dependent: :destroy" to the lock association to task model.

https://github.com/theforeman/foreman-tasks/commit/4c482f45f371edd0e71b5dc2d479c09ebdc52382#diff-20a816cf5bc6c5d3d8f9ff4de1395d55R21

Comment 3 Ivan Necas 2018-06-05 11:04:30 UTC
Created redmine issue http://projects.theforeman.org/issues/23814 from this bug

Comment 4 Satellite Program 2018-06-05 12:07:04 UTC
Upstream bug assigned to inecas

Comment 5 Satellite Program 2018-06-05 12:07:07 UTC
Upstream bug assigned to inecas

Comment 7 Satellite Program 2018-06-07 14:07:10 UTC
Moving this bug to POST for triage into Satellite 6 since the upstream issue http://projects.theforeman.org/issues/23814 has been resolved.

Comment 9 Patrick Creech 2018-07-02 20:06:18 UTC
Hey Ivan, this failed to cherrypick.  Can you take a look?

Comment 12 Mike McCune 2018-07-16 20:46:30 UTC
Turns out we are also missed the cleanup on dynflow_envelopes.

We can either manage this as a different bug or include it in this bug

Comment 13 Ivan Necas 2018-07-17 07:06:48 UTC
I would consider this being new bug, I will put it here once I file one

Comment 14 Kedar Bidarkar 2018-08-03 09:32:00 UTC
[root@sat63-rhel7 ~]# su - postgres -c "psql foreman -c 'select * from foreman_tasks_tasks'" |wc -l
91
[root@sat63-rhel7 ~]# su - postgres -c "psql foreman -c 'select * from foreman_tasks_locks'"|wc -l
523
[root@sat63-rhel7 ~]# foreman-rake foreman_tasks:cleanup TASK_SEARCH="" AFTER=1d

Cleaning up 519 orphaned locks

[root@sat63-rhel7 ~]# 
[root@sat63-rhel7 ~]# su - postgres -c "psql foreman -c 'select * from foreman_tasks_tasks'" |wc -l
7
[root@sat63-rhel7 ~]# su - postgres -c "psql foreman -c 'select * from foreman_tasks_locks'"|wc -l

As seen it has cleaned up 519 orphaned locks.

VERIFIED with Sat6.3.3 snap2

Comment 16 errata-xmlrpc 2018-08-22 20:07:12 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/RHBA-2018:2550