Bug 1766948

Summary: PG::ForeignKeyViolation when trying to add a relation to deleted users
Product: Red Hat Satellite Reporter: Evgeni Golov <egolov>
Component: Tasks PluginAssignee: Adam Ruzicka <aruzicka>
Status: CLOSED ERRATA QA Contact: Peter Ondrejka <pondrejk>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.4CC: aruzicka, inecas, pcreech
Target Milestone: 6.7.0Keywords: Triaged, Upgrades
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: tfm-rubygem-foreman-tasks-0.17.1-1.el7 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-04-14 13:26:24 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Evgeni Golov 2019-10-30 10:47:06 UTC
The migration added in https://projects.theforeman.org/issues/21083 / https://github.com/theforeman/foreman-tasks/pull/364 fails when migrating a task that references a (now) not existing user:

<pre>
[DEBUG 2019-10-30T11:03:33 main] PG::ForeignKeyViolation: ERROR:  insert or update on table "foreman_tasks_tasks" violates foreign key constraint "fk_rails_a56904dd86"
[DEBUG 2019-10-30T11:03:33 main] DETAIL:  Key (user_id)=(10) is not present in table "users".
[DEBUG 2019-10-30T11:03:33 main] : UPDATE "foreman_tasks_tasks" SET "user_id" = 10 WHERE "foreman_tasks_tasks"."id" IN (SELECT "foreman_tasks_tasks"."id" FROM "foreman_tasks_tasks" INNER JOIN "foreman_tasks_locks" ON "foreman_tasks_locks"."task_id" = "foreman_tasks_tasks"."id" WHERE "foreman_tasks_tasks"."id" IN (SELECT "foreman_tasks_locks"."task_id" FROM "foreman_tasks_locks" WHERE "foreman_tasks_locks"."name" = $1 AND "foreman_tasks_locks"."resource_id" = $2))
</pre>

Comment 1 Evgeni Golov 2019-10-30 10:47:10 UTC
Created from redmine issue https://projects.theforeman.org/issues/28152

Comment 2 Evgeni Golov 2019-10-30 10:47:13 UTC
Upstream bug assigned to None

Comment 4 Bryan Kearney 2019-11-06 11:02:28 UTC
Upstream bug assigned to aruzicka

Comment 5 Bryan Kearney 2019-11-06 11:02:30 UTC
Upstream bug assigned to aruzicka

Comment 6 Bryan Kearney 2019-11-06 15:02:21 UTC
Moving this bug to POST for triage into Satellite 6 since the upstream issue https://projects.theforeman.org/issues/28152 has been resolved.

Comment 7 Peter Ondrejka 2020-01-22 14:55:17 UTC
Verified on sat 6.7 snap 9 by deleting user from 6.6 and upgrading

Comment 10 errata-xmlrpc 2020-04-14 13:26:24 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-2020:1454