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
Created attachment 1971893 [details] production.log Attaching traceback for testcase failure
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.