Project

General

Profile

Actions

Bug #28152

closed

PG::ForeignKeyViolation when trying to add a relation to deleted users

Added by Evgeni Golov about 5 years ago. Updated about 5 years ago.

Status:
Closed
Priority:
High
Assignee:
Category:
-
Target version:
-
Difficulty:
Triaged:
No
Found in Releases:

Description

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:

[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))

Related issues 1 (0 open1 closed)

Related to foreman-tasks - Refactor #21083: Use explicit relation for task -> user associationClosedAdam RuzickaActions
Actions #1

Updated by Evgeni Golov about 5 years ago

  • Related to Refactor #21083: Use explicit relation for task -> user association added
Actions #2

Updated by Evgeni Golov about 5 years ago

  • Bugzilla link set to 1766948
Actions #3

Updated by Patrick Thyen about 5 years ago

After running a cleanup with:
"foreman-rake foreman_tasks:cleanup TASK_SEARCH='owner.id = 10' VERBOSE=true"
The Update works fine (assuming, there are no other deleted users, that trigger this problem).

Actions #4

Updated by The Foreman Bot about 5 years ago

  • Status changed from New to Ready For Testing
  • Assignee set to Adam Ruzicka
  • Pull request https://github.com/theforeman/foreman-tasks/pull/470 added
Actions #5

Updated by The Foreman Bot about 5 years ago

  • Fixed in Releases foreman-tasks-0.17.1 added
Actions #6

Updated by Anonymous about 5 years ago

  • Status changed from Ready For Testing to Closed
Actions #7

Updated by Adam Ruzicka about 5 years ago

  • Fixed in Releases foreman-tasks-0.16.3 added
Actions

Also available in: Atom PDF