Bug 1503176 - Liquibase migration fails when activation keys referencing missing products exist
Summary: Liquibase migration fails when activation keys referencing missing products e...
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Candlepin
Classification: Community
Component: candlepin
Version: 2.2
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
: 2.2
Assignee: Alex Wood
QA Contact: Katello QA List
URL:
Whiteboard:
: 1510011 (view as bug list)
Depends On:
Blocks: 1503179
TreeView+ depends on / blocked
 
Reported: 2017-10-17 13:39 UTC by Alex Wood
Modified: 2021-09-09 12:43 UTC (History)
9 users (show)

Fixed In Version: candlepin-2.3.1-1
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
: 1503177 1503179 (view as bug list)
Environment:
Last Closed: 2019-04-04 13:22:37 UTC
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github candlepin candlepin pull 1756 0 None closed 1503176: Delete missing products from activation keys while upgrading. 2020-06-18 05:26:23 UTC

Description Alex Wood 2017-10-17 13:39:45 UTC
Description of problem:

When migrating from 0.9.54 to 2.x, if a database has activation keys that are referencing products that have been deleted, the migration will fail.  The failure occurs in PerOrgsProductsMigrationTask due to the presence of the records in cp_activationkey_product that reference the missing products.

Version-Release number of selected component (if applicable): 2.x series

How reproducible: Always

Steps to Reproduce:
1. Starting with 0.9.54, create an activation key using a productId that does not exist.
2. Attempt to migrate to candlepin 2.0.

liquibase --driver=org.postgresql.Driver --classpath=/usr/share/java/postgresql-jdbc.jar:/var/lib/tomcat/webapps/candlepin/WEB-INF/classes/ --changeLogFile=db/changelog/changelog-update.xml --url=jdbc:postgresql:candlepin --username=candlepin  --password=<PASSWORD> migrate -Dcommunity=False

Actual results:

Liquibase update Failed: Migration failed for change set db/changelog/20150210094558-perorgproducts-phase-1.xml::20150210094558-35::crog:
     Reason: liquibase.exception.UnexpectedLiquibaseException: liquibase.exception.CustomChangeException: liquibase.exception.DatabaseException: One or more orgs failed data validation

Expected results:

Successful migration

Comment 1 Ivan Necas 2017-11-07 11:52:58 UTC
*** Bug 1510011 has been marked as a duplicate of this bug. ***

Comment 9 Kavita 2017-11-21 06:17:37 UTC
To add pre-upgrade check to detect if any bad content definition, created new BZ under Foreman-Maintain. This check will provide a step for user to delete bad content if any. 

Reference link - https://bugzilla.redhat.com/show_bug.cgi?id=1515614


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