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 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
Summary: Upgrade to Satellite 6.9 fails at db:migrate stage with 'could not create uni...
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: Upgrades
Version: 6.9.0
Hardware: All
OS: All
high
high
Target Milestone: 6.10.0
Assignee: Ondřej Ezr
QA Contact: Devendra Singh
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2021-05-14 06:30 UTC by Sayan Das
Modified: 2021-09-07 11:15 UTC (History)
5 users (show)

Fixed In Version: foreman-2.5.1
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
: 1985330 (view as bug list)
Environment:
Last Closed: 2021-09-07 09:44:53 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Foreman Issue Tracker 32673 0 High Closed Migrations fail with 'could not create unique index "index_lookup_values_on_lookup_key_id_and_match"' error 2021-07-22 16:00:15 UTC
Red Hat Knowledge Base (Solution) 6029911 0 None None None 2021-05-14 06:30:30 UTC

Description Sayan Das 2021-05-14 06:30:16 UTC
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

Comment 7 Ondřej Ezr 2021-05-31 10:12:37 UTC
Created redmine issue https://projects.theforeman.org/issues/32673 from this bug

Comment 8 Bryan Kearney 2021-05-31 12:03:37 UTC
Upstream bug assigned to oezr

Comment 9 Bryan Kearney 2021-05-31 12:03:40 UTC
Upstream bug assigned to oezr

Comment 10 Bryan Kearney 2021-06-02 12:03:25 UTC
Moving this bug to POST for triage into Satellite since the upstream issue https://projects.theforeman.org/issues/32673 has been resolved.

Comment 16 Ondřej Ezr 2021-09-07 09:44:53 UTC
I believe we can :+1:


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