Bug 2081931

Summary: PG::ForeignKeyViolation: ERROR: update or delete on table "katello_erratum_packages" violates foreign key constraint "katello_msep_erratum_package_id_fk" on table "katello_module_stream_erratum_packages"
Product: Red Hat Satellite Reporter: matt jia <mjia>
Component: Errata ManagementAssignee: Samir Jha <sajha>
Status: CLOSED ERRATA QA Contact: Lukas Pramuk <lpramuk>
Severity: high Docs Contact:
Priority: high    
Version: 6.10.5CC: ahumbe, avnkumar, dgupte, dhjoshi, jbhatia, jkrajice, lpramuk, mkalyat, mveiga, oliver, osousa, pcreech, pdwyer, pmendezh, sadas, sajha, saydas, sraut
Target Milestone: 6.10.5Keywords: Triaged, Upgrades
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: tfm-rubygem-katello-4.1.1.56-1.el7sat Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 2083532 (view as bug list) Environment:
Last Closed: 2022-05-11 16:28:08 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:
Bug Depends On:    
Bug Blocks: 2083532    

Description matt jia 2022-05-05 02:56:17 UTC
Description of problem:


Upgrading to 6.10.5 fails with below error:


root@ctqlsat06 ~]# foreman-rake db:migrate --trace --verbose
'ErbParser' is ignored.
'RubyParser' is ignored.
** Invoke db:migrate (first_time)
** Invoke db:load_config (first_time)
** Invoke environment (first_time)
** Execute environment
API controllers newer than Apipie cache! Run apipie:cache rake task to regenerate cache.
** Execute db:load_config
** Invoke plugin:refresh_migrations (first_time)
** Invoke environment
** Execute plugin:refresh_migrations
** Execute db:migrate
== 20220303160220 RemoveDuplicateErrata: migrating ============================
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:

PG::ForeignKeyViolation: ERROR:  update or delete on table "katello_erratum_packages" violates foreign key constraint "katello_msep_erratum_package_id_fk" on table "katello_module_stream_erratum_packages"
DETAIL:  Key (id)=(264838) is still referenced from table "katello_module_stream_erratum_packages".
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/connection_adapters/postgresql_adapter.rb:675:in `async_exec_params'


Version-Release number of selected component (if applicable):


How reproducible:

Unknown as it happens on one of the customers' Satellite


Steps to Reproduce:
1.
2.
3.

Actual results:

failed upgrade due to failing db:migrate

Expected results:

successful upgrade

Additional info:

It's quite similar to bz#2075519, but this happens on a different table.

Comment 2 Samir Jha 2022-05-05 20:47:08 UTC
Created redmine issue https://projects.theforeman.org/issues/34870 from this bug

Comment 11 Bryan Kearney 2022-05-09 16:05:18 UTC
Moving this bug to POST for triage into Satellite since the upstream issue https://projects.theforeman.org/issues/34870 has been resolved.

Comment 14 Lukas Pramuk 2022-05-10 15:49:30 UTC
VERIFIED.

@Satellite 6.10.5.1 Snap1
tfm-rubygem-katello-4.1.1.56-1.el7sat.noarch

by the following manual reproducer:

1) Have a Satellite 6.10.z

2) Sync RHEL8 (BaseOS, Appstream) repos !!!

3) Upgrade to 6.10.5.1

# satellite-maintain upgrade run --target-version 6.10.z -y -w repositories-validate,repositories-setup
...

Running Migration scripts to Satellite 6.10.z
================================================================================
Setup repositories:                                                   [SKIPPED]
--------------------------------------------------------------------------------
Unlock packages:                                                      [OK]
--------------------------------------------------------------------------------
Update package(s) :                                                   [OK]
--------------------------------------------------------------------------------
Procedures::Installer::Upgrade:                                       [OK]
--------------------------------------------------------------------------------
Execute upgrade:run rake task:                                        [OK]
--------------------------------------------------------------------------------
...

Upgrade finished.

>>> upgrade to 6.10.5.1 is successful

Comment 19 errata-xmlrpc 2022-05-11 16:28:08 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 (Satellite 6.10.5.1 Async 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/RHBA-2022:2203