Bug 2224031

Summary: Repository sync failed with error "ERROR: insert or update on table "katello_repository_rpms"
Product: Red Hat Satellite Reporter: mithun kalyat <mkalyat>
Component: RepositoriesAssignee: Samir Jha <sajha>
Status: CLOSED ERRATA QA Contact: Cole Higgins <chiggins>
Severity: high Docs Contact:
Priority: high    
Version: 6.14.0CC: ahumbe, amahindr, amiagarw, chiggins, iballou, rlavi, sajha, vijsingh
Target Milestone: 6.14.0Keywords: 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: 2023-11-08 14:19:57 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:

Description mithun kalyat 2023-07-19 15:52:30 UTC
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.

Comment 4 Ian Ballou 2023-07-25 20:53:10 UTC
I was able to reproduce it. It's on our board to fix. Adding 6.14.0+.

Comment 5 Ian Ballou 2023-07-25 20:54:57 UTC
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.

Comment 6 Ian Ballou 2023-07-25 20:56:23 UTC
Bumping priority since it's a sync blocker.

Comment 7 Samir Jha 2023-07-26 17:57:17 UTC
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.

Comment 9 Ron Lavi 2023-07-31 12:25:45 UTC
*** Bug 2224738 has been marked as a duplicate of this bug. ***

Comment 13 Brad Buckingham 2023-08-11 12:02:56 UTC
*** Bug 2226667 has been marked as a duplicate of this bug. ***

Comment 17 errata-xmlrpc 2023-11-08 14:19:57 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (Important: Satellite 6.14 security and bug fix update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2023:6818