Bug 2087727 - 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"
Summary: Upgrade to Satellite 6.10.5.1 fails with error message "PG::NotNullViolation:...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: Errata Management
Version: 6.10.5
Hardware: All
OS: Linux
high
high
Target Milestone: 6.11.0
Assignee: Samir Jha
QA Contact: Lukas Pramuk
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2022-05-18 11:05 UTC by dgupte
Modified: 2024-03-06 13:05 UTC (History)
7 users (show)

Fixed In Version: tfm-rubygem-katello-4.3.0.40-1
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
: 2093405 (view as bug list)
Environment:
Last Closed: 2022-07-05 14:35:42 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Foreman Issue Tracker 34944 0 High Closed Upgrade to Satellite 6.10.5.1 fails with error message "PG::NotNullViolation: ERROR: null value in column "erratum_packa... 2022-05-31 15:22:00 UTC
Red Hat Knowledge Base (Solution) 6961411 0 None None None 2022-06-01 04:50:07 UTC
Red Hat Product Errata RHSA-2022:5498 0 None None None 2022-07-05 14:35:49 UTC

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


Note You need to log in before you can comment on or make changes to this bug.