Description of problem: I have enabled the following repositories and triggered sync for the first time on all 4 of them simultaneously. Red Hat Enterprise Linux 8 for x86_64 - AppStream RPMs 8 Red Hat Enterprise Linux 8 for x86_64 - BaseOS RPMs 8 Red Hat Enterprise Linux 8 for x86_64 - AppStream Kickstart 8.7 Red Hat Enterprise Linux 8 for x86_64 - BaseOS Kickstart 8.7 Only 'Red Hat Enterprise Linux 8 for x86_64 - BaseOS RPMs 8' sync failed with the following error. PG::ForeignKeyViolation: ERROR: insert or update on table "katello_repository_rpms" violates foreign key constraint "fk_rails_39a260fd51" DETAIL: Key (rpm_id)=(5304) is not present in table "katello_rpms". Res-sync of the above repository fixed the issue. I can't reproduce it for RHEL 9 same set repositories.
I was able to reproduce it. It's on our board to fix. Adding 6.14.0+.
I reproduced the issue by syncing 4 RHEL repos (RHEL 8 and RHEL 9 AppStream + BaseOS) at the same time like noted in the BZ description.
Bumping priority since it's a sync blocker.
Looking at the error and failure in index action when reproducing, the reason the RPM might have been deleted before a RepositoryRPM is created as the error says is because we had a delete_orphan task being invoked in index_action which would delete all content which hadn't been associated to a repository. Looks like a race condition side effect from that. We have removed delete_orphan from index action in snap 8 as part of this BZ: https://bugzilla.redhat.com/show_bug.cgi?id=2221291 so this should be resolved. Currently testing on a second snap 8 instance.
*** Bug 2224738 has been marked as a duplicate of this bug. ***
*** Bug 2226667 has been marked as a duplicate of this bug. ***