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
Created redmine issue https://projects.theforeman.org/issues/34944 from this bug
Moving this bug to POST for triage into Satellite since the upstream issue https://projects.theforeman.org/issues/34944 has been resolved.
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
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