Red Hat Bugzilla – 1960530 – Upgrade to Satellite 6.9 fails at db:migrate stage with 'could not create unique index "index_lookup_values_on_lookup_key_id_and_match"' error
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.
Description of problem:
While attempting to upgrade the Red Hat Satellite server 6.8 to 6.9, It fails at the db:migrate stage with this error
PG::UniqueViolation: ERROR: could not create unique index "index_lookup_values_on_lookup_key_id_and_match"
DETAIL: Key (lookup_key_id, match)=(146, fqdn=myhost.example.com) is duplicated.
Version-Release number of selected component (if applicable):
Satellite 6.9 [ 6.8 to 6.9 upgrade ]
How reproducible:
Under specific circumstances i.e. when lookup_values table has duplicate record
Steps to reproduce:
1. Install and configure Satellite 6.8
2. Import some puppet modules and create some puppet smart class overrides
3. Find a way to create a duplicate override record of one of the puppet smart class parameters inside lookup_values table
4. Perform the upgrade to 6.9
Actual Results:
db:migrate stage will fail at following
StandardError: An error has occurred, this and all later migrations canceled:
PG::UniqueViolation: ERROR: could not create unique index "index_lookup_values_on_lookup_key_id_and_match"
DETAIL: Key (lookup_key_id, match)=(146, fqdn=myhost.example.com) is duplicated.
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.4/lib/active_record/connection_adapters/postgresql/database_statements.rb:92:in `async_exec'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.4/lib/active_record/connection_adapters/postgresql/database_statements.rb:92:in `block (2 levels) in execute'
/opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.3.4/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
Expected results:
Before the db:migrate happens, these inconsistencies should be properly detected, printed and if needed cleared up.
Additional Information:
Manual Solution present in https://access.redhat.com/solutions/6029911 i.e. to identify the duplicate record and delete the one which is not needed.
Also see --> https://community.theforeman.org/t/upgrade-from-foreman-2-1-to-2-2-failed-with-postgres-error/21443