Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
Red Hat Satellite engineering is moving the tracking of its product development work on Satellite to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "Satellite project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs will be migrated starting at the end of May. If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "Satellite project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/SAT-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 2087727

Summary: Upgrade to Satellite 6.10.5.1 fails with error message "PG::NotNullViolation: ERROR: null value in column "erratum_package_id" violates not-null constraint"
Product: Red Hat Satellite Reporter: dgupte
Component: Errata ManagementAssignee: Samir Jha <sajha>
Status: CLOSED ERRATA QA Contact: Lukas Pramuk <lpramuk>
Severity: high Docs Contact:
Priority: high    
Version: 6.10.5CC: avnkumar, damoore, jbhatia, lpramuk, msunil, pcreech, sajha
Target Milestone: 6.11.0Keywords: Triaged, Upgrades
Target Release: Unused   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: tfm-rubygem-katello-4.3.0.40-1 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 2093405 (view as bug list) Environment:
Last Closed: 2022-07-05 14:35:42 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 dgupte 2022-05-18 11:05:47 UTC
Description of problem:
>>
ActiveRecord::NotNullViolation: PG::NotNullViolation: ERROR:  null value in column "erratum_package_id" violates not-null constraint
DETAIL:  Failing row contains (6951, 391, null, 2021-09-01 15:01:50.648184, 2022-05-18 08:36:49.305383).

Version-Release number of selected component (if applicable):
>>
satellite-6.10.5.1-1.el7sat.noarch


Actual results:
>> Upgrade fails at db migrate stage

Expected results:
>> Upgrade should be successful. 

Additional info:
>> 
Following bugzilla related to "20220303160220_remove_duplicate_errata.rb" which is resolved in RHBA-2022:2203. However, it looks hitting the similar error for a different table. 

https://bugzilla.redhat.com/show_bug.cgi?id=2075519
https://bugzilla.redhat.com/show_bug.cgi?id=2081931

Comment 2 Samir Jha 2022-05-19 16:10:41 UTC
Created redmine issue https://projects.theforeman.org/issues/34944 from this bug

Comment 6 Bryan Kearney 2022-05-26 20:04:29 UTC
Moving this bug to POST for triage into Satellite since the upstream issue https://projects.theforeman.org/issues/34944 has been resolved.

Comment 8 Lukas Pramuk 2022-06-12 15:14:26 UTC
VERIFIED.

@Satellite 6.11.0 Snap23
tfm-rubygem-katello-4.3.0.41-1.el7sat.noarch

by adjusting the manual reproducer described in https://github.com/Katello/katello/pull/10122#issue-1242021500 and https://github.com/Katello/katello/pull/10122#issuecomment-1138943706

1) Have a Satellite 6.11.0 Snap22


2) Sync only RHEL8 Appstream repo
# hammer repository-set enable  --organization-id 1 --name 'Red Hat Enterprise Linux 8 for x86_64 - AppStream (RPMs)' --basearch x86_64 --releasever 8
# hammer product synchronize --name 'Red Hat Enterprise Linux for x86_64' --organization-id 1 --async


3) Use foreman console to produce partly migrated duplicate errata
# foreman-rake console
Loading production environment (Rails 6.0.4.7)
> ::Katello::ModuleStreamErratumPackage.count
=> 10223

> ::Katello::Erratum.all.each do |errata|
    errata.pulp_id = errata.errata_id + 'random'
    errata.save!
end

> Katello::Repository.count
=> 1

> repo = ::Katello::Repository.first
=> #<Katello::Repository id: 1, pulp_id: "f35b4786-bf71-4ff8-af44-baf1a5f2f6b2", library_instance_id: nil, content_...

> repo.index_content

> ::Katello::ModuleStreamErratumPackage.count
=> 10223

> original = Katello::Erratum.find_by(pulp_id: 'RHBA-2022:1816')
=> #<Katello::Erratum id: 2282, pulp_id: "RHBA-2022:1816", errata_id: "RHBA-2022:1816", created_at: "2022-06-10 15:...

> Katello::ModuleStreamErratumPackage.where(erratum_package_id: Katello::ErratumPackage.where(erratum_id:
 original.id)).destroy_all
=> []

> Katello::ErratumPackage.where(erratum_id: original.id).destroy_all
=> []


4) Tear down the migration
# foreman-rake db:migrate:down VERSION=20220303160220
== 20220303160220 RemoveDuplicateErrata: reverting ============================
== 20220303160220 RemoveDuplicateErrata: reverted (0.0000s) ===================

5) Run db:migrate
# foreman-rake db:migrate
== 20220303160220 RemoveDuplicateErrata: migrating ============================
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:

PG::InFailedSqlTransaction: ERROR:  current transaction is aborted, commands ignored until end of transaction block
...

Caused by:
ActiveRecord::NotNullViolation: PG::NotNullViolation: ERROR:  null value in column "erratum_package_id" violates not-null constraint
DETAIL:  Failing row contains (1, 508, null, 2022-06-10 14:38:13.486843, 2022-06-10 17:19:38.717716).
...

>>> successfully reproduced


6) Adjust internal repo to Snap23 and perform upgrade from Snap22 to Snap23 (6.11.z target version)
# satellite-maintain upgrade run --target-version 6.11.z -y -w repositories-validate,repositories-setup


7) Check migration status explicitly
# foreman-rake db:migrate:status | grep 20220303160220
   up     20220303160220  Remove duplicate errata

>>> successfully verified

Comment 11 errata-xmlrpc 2022-07-05 14:35:42 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 (Moderate: Satellite 6.11 Release), 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-2022:5498