Bug 2216471

Summary: Can't delete host right after facts gathered - foreign key violation
Product: Red Hat Satellite Reporter: Lukáš Hellebrandt <lhellebr>
Component: FactAssignee: satellite6-bugs <satellite6-bugs>
Status: CLOSED MIGRATED QA Contact: visawant
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.14.0CC: rlavi, shwsingh
Target Milestone: UnspecifiedKeywords: MigratedToJIRA, Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2024-06-06 16:22:48 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:
Attachments:
Description Flags
production.log none

Description Lukáš Hellebrandt 2023-06-21 14:19:21 UTC
Description of problem:
Sometimes, when I try to delete a host right after I played its ansible roles and facts import got triggered in background, I get ISE and a foreign key violation. Looks like race condition when host deleting starts and before it is finished, its facts are imported and deletion fails.

Version-Release number of selected component (if applicable):
Reproduced on Sat 6.15 stream snap 18.0, I don't have a reason to think it's a regression but I haven't tested.

How reproducible:
Random. I was able to reproduce in automation using API when the client was RHEL8, perhaps because it has more facts than RHEL7. Adding a few seconds sleep between play-roles and host delete proved as workaround.

Steps to Reproduce:
Run facts on a RHEL8 host and delete it immediately.

Actual results:
ISE 500:
Backtrace for 'Action failed' error (ActiveRecord::InvalidForeignKey): PG::ForeignKeyViolation: ERROR:  update or delete on table "hosts" violates foreign key constraint "fact_values_host_id_fk" on table "fact_values"

Expected results:
Host removed, or at least delete failed gracefully

Additional info:
production.log including traceback attached

Comment 1 Lukáš Hellebrandt 2023-06-21 14:27:18 UTC
Created attachment 1971893 [details]
production.log

Attaching traceback for testcase failure

Comment 2 Lukáš Hellebrandt 2023-06-21 14:37:17 UTC
Created attachment 1971894 [details]
production.log.pass

Attaching a log for instance where it passed. Note a different order of fact import action and host delete action. Where it failed, import finished after delete started.

Comment 3 Eric Helms 2024-06-06 16:22:48 UTC
This BZ has been automatically migrated to the issues.redhat.com Red Hat Issue Tracker. All future work related to this report will be managed there.

Due to differences in account names between systems, some fields were not replicated.  Be sure to add yourself to Jira issue's "Watchers" field to continue receiving updates and add others to the "Need Info From" field to continue requesting information.

To find the migrated issue, look in the "Links" section for a direct link to the new issue location. The issue key will have an icon of 2 footprints next to it, and begin with "SAT-" followed by an integer.  You can also find this issue by visiting https://issues.redhat.com/issues/?jql= and searching the "Bugzilla Bug" field for this BZ's number, e.g. a search like:

"Bugzilla Bug" = 1234567

In the event you have trouble locating or viewing this issue, you can file an issue by sending mail to rh-issues. You can also visit https://access.redhat.com/articles/7032570 for general account information.