Repository: ambari Updated Branches: refs/heads/branch-2.6 34dc30941 -> f8c66dd05 refs/heads/trunk df1081378 -> e219186ea
AMBARI-22216. Ambari Schema Upgrade Failed during Ambari Upgrade - workaround (dlysnichenko) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/f8c66dd0 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/f8c66dd0 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/f8c66dd0 Branch: refs/heads/branch-2.6 Commit: f8c66dd050dd29e769e3300831ca1e25dba46233 Parents: 34dc309 Author: Lisnichenko Dmitro <[email protected]> Authored: Mon Oct 16 12:13:01 2017 +0300 Committer: Lisnichenko Dmitro <[email protected]> Committed: Mon Oct 16 12:13:01 2017 +0300 ---------------------------------------------------------------------- .../ambari/server/upgrade/UpgradeCatalog260.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/f8c66dd0/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog260.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog260.java b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog260.java index c701bdb..6f37985 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog260.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog260.java @@ -79,6 +79,7 @@ public class UpgradeCatalog260 extends AbstractUpgradeCatalog { public static final String DESIRED_REPO_VERSION_ID_COLUMN = "desired_repo_version_id"; public static final String REPO_STATE_COLUMN = "repo_state"; public static final String FK_SCDS_DESIRED_STACK_ID = "FK_scds_desired_stack_id"; + public static final String FK_SERVICECOMPONENTDESIREDSTATE_DESIRED_STACK_ID = "FK_servicecomponentdesiredstate_desired_stack_id"; public static final String FK_SCDS_DESIRED_REPO_ID = "FK_scds_desired_repo_id"; public static final String REPO_VERSION_TABLE = "repo_version"; @@ -151,6 +152,9 @@ public class UpgradeCatalog260 extends AbstractUpgradeCatalog { public static final String STALE_POSTGRESS_USERS_LDAP_USER_KEY = "users_ldap_user_key"; public static final String SHORT_URL_COLUMN = "short_url"; public static final String FK_INSTANCE_URL_ID = "FK_instance_url_id"; + public static final String FK_SERVICEDESIREDSTATE_DESIRED_STACK_ID = "FK_servicedesiredstate_desired_stack_id"; + public static final String FK_HOSTCOMPONENTDESIREDSTATE_DESIRED_STACK_ID = "FK_hostcomponentdesiredstate_desired_stack_id"; + public static final String FK_HOSTCOMPONENTSTATE_CURRENT_STACK_ID = "FK_hostcomponentstate_current_stack_id"; /** @@ -186,6 +190,7 @@ public class UpgradeCatalog260 extends AbstractUpgradeCatalog { @Override protected void executeDDLUpdates() throws AmbariException, SQLException { int currentVersionID = getCurrentVersionID(); + dropBrokenFK(); updateServiceComponentDesiredStateTable(currentVersionID); updateServiceDesiredStateTable(currentVersionID); addSelectedCollumsToClusterconfigTable(); @@ -202,6 +207,20 @@ public class UpgradeCatalog260 extends AbstractUpgradeCatalog { removeStaleConstraints(); } + /** + * Drop broken FK + * {@value #FK_SERVICECOMPONENTDESIREDSTATE_DESIRED_STACK_ID} + * {@value #FK_SERVICEDESIREDSTATE_DESIRED_STACK_ID} + * {@value #FK_HOSTCOMPONENTDESIREDSTATE_DESIRED_STACK_ID} + * {@value #FK_HOSTCOMPONENTSTATE_CURRENT_STACK_ID} + */ + private void dropBrokenFK() throws SQLException { + dbAccessor.dropFKConstraint(SERVICE_COMPONENT_DESIRED_STATE_TABLE, FK_SERVICECOMPONENTDESIREDSTATE_DESIRED_STACK_ID); + dbAccessor.dropFKConstraint(SERVICE_DESIRED_STATE_TABLE, FK_SERVICEDESIREDSTATE_DESIRED_STACK_ID); + dbAccessor.dropFKConstraint(HOST_COMPONENT_DESIRED_STATE_TABLE, FK_HOSTCOMPONENTDESIREDSTATE_DESIRED_STACK_ID); + dbAccessor.dropFKConstraint(HOST_COMPONENT_STATE_TABLE, FK_HOSTCOMPONENTSTATE_CURRENT_STACK_ID); + } + /** * Updates {@value #VIEWURL_TABLE} table.
