Project

General

Profile

Actions

Bug #32492

closed

Unable to delete old host "PG::ForeignKeyViolation: ERROR: update or delete on table "hosts" violates foreign key constraint "fk_rails_4c747e18cb" on table "registration_facets" DETAIL: Key (id)=(40) is still referenced from table "registration_facets".

Added by Oliver Weinmann almost 3 years ago. Updated over 2 years ago.

Status:
Resolved
Priority:
Normal
Assignee:
-
Category:
-
Target version:
-
Difficulty:
Triaged:
No
Fixed in Releases:
Found in Releases:

Description

Hi,

Running up to date Katello 3.18.2. I'm not able to delete old hosts. When trying to delete an old host, the following error is shown:

"PG::ForeignKeyViolation: ERROR: update or delete on table "hosts" violates foreign key constraint "fk_rails_4c747e18cb" on table "registration_facets" DETAIL: Key (id)=(40) is still referenced from table "registration_facets".

Deleting newly created hosts is possible.

Googling for the error came up with this:

https://community.theforeman.org/t/cant-delete-any-hosts-after-upgrade-to-katello-3-18/21998

which lead me to a reported bug.

https://projects.theforeman.org/issues/31669

Unfortunately the fix doesn't work for me.

Best Regards,
Oliver

Actions #1

Updated by Ian Ballou almost 3 years ago

  • Target version set to Katello 3.18.4
  • Triaged changed from No to Yes
Actions #2

Updated by Jonathon Turel almost 3 years ago

Hi Oliver. Are you able to delete the hosts after doing a complete restart of foreman services? foreman-maintain service restart is the command to run on your server

Actions #3

Updated by Jonathon Turel almost 3 years ago

  • Status changed from New to Need more information
  • Target version deleted (Katello 3.18.4)
  • Triaged changed from Yes to No
Actions #4

Updated by Jonathon Turel almost 3 years ago

  • Project changed from Katello to Foreman
Actions #5

Updated by Oliver Weinmann almost 3 years ago

Hi Jonathon,

sorry for my late reply. I did restart katello a couple of times due to some other issues I have. This morning I tried to delete the host again and it still fails. I checked the dynflow console and the subtasks and the error is still the same:

ActiveRecord::InvalidForeignKey: PG::ForeignKeyViolation: ERROR: update or delete on table "hosts" violates foreign key constraint "fk_rails_4c747e18cb" on table "registration_facets"
DETAIL: Key (id)=(40) is still referenced from table "registration_facets".

So it is failing to unregister the host as content host. I manually trid to unregister it but as expected, this also fails. I renamed the host, but this also doesn't work.

Best Regards,
Oliver

Actions #6

Updated by Oliver Weinmann almost 3 years ago

  • Status changed from Need more information to Resolved

I can't remeber how, but I managed to get rid of the host. Ticket closed. :)

Actions #7

Updated by r0k5t4r please_edit_me over 2 years ago

Hi,

sorry I have to open this one again. The problem still persists. I must have mistakenly reported the machine as deleted. I'm now running latest Katello 3.18 and the problem still exists. I have recreated the VM and registered it as content host. Tried deleting -> doesn't work, same error.

PG::ForeignKeyViolation: ERROR: update or delete on table "hosts" violates foreign key constraint "fk_rails_4c747e18cb" on table "registration_facets" DETAIL: Key (id)=(40) is still referenced from table "registration_facets".

It is not a big problem but it would be nice to get rid of the machine. :)

Best Regards,
Oliver

Actions #8

Updated by Jonathon Turel over 2 years ago

Hi there,

Here's something that should get you going:

1. Take a backup of your instance
2. Log in as root and run 'foreman-admin'
3. Find the registration facet that's referring to your host: ForemanRegister::RegistrationFacet.where(host_id: $HOST_ID)

Verify that you get one result

4. Then, delete that registration facet: ForemanRegister::RegistrationFacet.where(host_id: $HOST_ID).destroy_all

That should work for you for now! I don't know the root cause of the bug but I think it's been fixed. Definitely recommend updating to 4.1 at least since 3.18 is no longer supported. In the future, please inquire about support in our community forum: https://community.theforeman.org/c/support/10 as you can get support from a much wider audience of folks!

Jonathon

Actions #9

Updated by r0k5t4r please_edit_me over 2 years ago

Hi Jonathon,

thanks a lot. I didn't have "foreman-admin" but I used "foreman-rake console" instead. All fixed now. :)

Actually I do make use of the community a lot. But I didn't want to duplicate my problem. I just recently had my journey upgrading to Pulp3, this took me ages to fix. :) I would love to upgrade to Katello 4.x but we are still relying on a couple of puppet modules and have to replace them with ansible roles first. As if I understood correctly from the docs in Katello 4.x puppet repos are no longer supported. But that is a bit off topic now.

Best Regards,
Oliver

Actions

Also available in: Atom PDF