Bug 1375029
Summary: | db:migrate failure during upgrade from 3.2 to 4.1 | |||
---|---|---|---|---|
Product: | Red Hat CloudForms Management Engine | Reporter: | Colin Arnott <carnott> | |
Component: | Appliance | Assignee: | Nick Carboni <ncarboni> | |
Status: | CLOSED CURRENTRELEASE | QA Contact: | luke couzens <lcouzens> | |
Severity: | high | Docs Contact: | ||
Priority: | high | |||
Version: | 5.6.0 | CC: | abellott, benglish, fahmed, fdewaley, gtanzill, jhardy, ncarboni, ngupta, obarenbo, simaishi, tachoi | |
Target Milestone: | GA | Keywords: | TestOnly, ZStream | |
Target Release: | 5.7.0 | |||
Hardware: | x86_64 | |||
OS: | Linux | |||
Whiteboard: | upgrade:migration | |||
Fixed In Version: | 5.7.0.2 | Doc Type: | If docs needed, set a value | |
Doc Text: | Story Points: | --- | ||
Clone Of: | ||||
: | 1377418 (view as bug list) | Environment: | ||
Last Closed: | 2017-01-11 19:55:55 UTC | Type: | Bug | |
Regression: | --- | Mount Type: | --- | |
Documentation: | --- | CRM: | ||
Verified Versions: | Category: | --- | ||
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | ||
Cloudforms Team: | --- | Target Upstream Version: | ||
Embargoed: | ||||
Bug Depends On: | ||||
Bug Blocks: | 1377418 |
Description
Colin Arnott
2016-09-12 00:14:10 UTC
Was able to recreated the issue in lab appBiance with customer provided db dump. With some internal research(Case:01684595,bug: 1368192) now I am able to import customer db dump after truncating some tables. psql -U root -d vmdb_production -c 'truncate miq_roles_features;' psql -U root -d vmdb_production -c 'truncate time_profiles;' Just want to get a confirmation from engineering to see if this is safe to proceed Taeho In nearly all cases it is not okay to just truncate tables. In this case specifically that data will not be recreated and would be lost, corrupting the link between the miq_user_roles and miq_product_features table. Is there an environment with the issue recreated that I can look at? The following three queries should fix the issue: -- create a temp table of the duplicates CREATE TEMP TABLE duplicate_miq_roles_features AS ( SELECT miq_user_role_id, miq_product_feature_id FROM miq_roles_features GROUP BY miq_user_role_id, miq_product_feature_id HAVING COUNT(*) > 1 ); -- delete the duplicate rows DELETE FROM miq_roles_features mrf WHERE EXISTS( SELECT 1 FROM duplicate_miq_roles_features dups WHERE dups.miq_user_role_id = mrf.miq_user_role_id AND dups.miq_product_feature_id = mrf.miq_product_feature_id ); -- insert one copy of each of the duplicate sets INSERT INTO miq_roles_features( SELECT * FROM duplicate_miq_roles_features ); As a part of this fix I will look into removing the migration that adds composite keys to the join tables, as those will be removed in a later migration. Initial migration to add composite keys: https://github.com/ManageIQ/manageiq/blob/master/db/migrate/20160106214719_add_composite_primary_keys_to_join_tables.rb Migration that removes composite keys: https://github.com/ManageIQ/manageiq/blob/master/db/migrate/20160406195810_add_id_primary_key_to_join_tables.rb Because both changes (adding the migrations) are contained in the same set of releases it should be safe to remove the offsetting migrations. New commit detected on ManageIQ/manageiq/master: https://github.com/ManageIQ/manageiq/commit/3ed51d47b6231eb328aea5a423cc5ff9f35b98e8 commit 3ed51d47b6231eb328aea5a423cc5ff9f35b98e8 Author: Nick Carboni <ncarboni> AuthorDate: Mon Sep 12 15:12:01 2016 -0400 Commit: Nick Carboni <ncarboni> CommitDate: Mon Sep 12 15:15:55 2016 -0400 Remove composite primary key migration logic with no net effect Originally, composite primary keys were added to join tables so that pglogical replication would work properly. This change was reverted and id primary keys were added in a following migration. Adding composite primary keys is now failing some migrations in live environments because rows in join tables seem to have duplicates in some cases. Removing this logic will allow those migrations to go much more smoothly. https://bugzilla.redhat.com/show_bug.cgi?id=1375029 ...19_add_composite_primary_keys_to_join_tables.rb | 33 ---------------------- ...0406195810_add_id_primary_key_to_join_tables.rb | 29 ------------------- ...95810_add_id_primary_key_to_join_tables_spec.rb | 10 ------- 3 files changed, 72 deletions(-) delete mode 100644 db/migrate/20160106214719_add_composite_primary_keys_to_join_tables.rb *** Bug 1367127 has been marked as a duplicate of this bug. *** |