You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by dm...@apache.org on 2017/10/19 15:58:15 UTC

[2/2] ambari git commit: AMBARI-22216. Ambari Schema Upgrade Failed during Ambari Upgrade (configuration: 2.5.2.0 -> 2.6.0.0 upgrade) (dlysnichenko)

AMBARI-22216. Ambari Schema Upgrade Failed during Ambari Upgrade (configuration: 2.5.2.0 -> 2.6.0.0 upgrade) (dlysnichenko)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/e76b5636
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/e76b5636
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/e76b5636

Branch: refs/heads/trunk
Commit: e76b5636ffd345f13ed7a98f7ee8f5fd5d9eb2d6
Parents: 15cec1c
Author: Lisnichenko Dmitro <dl...@hortonworks.com>
Authored: Thu Oct 19 18:56:31 2017 +0300
Committer: Lisnichenko Dmitro <dl...@hortonworks.com>
Committed: Thu Oct 19 18:58:03 2017 +0300

----------------------------------------------------------------------
 .../java/org/apache/ambari/server/orm/DBAccessorImpl.java    | 8 ++++++--
 .../org/apache/ambari/server/upgrade/UpgradeCatalog260.java  | 6 ++++++
 2 files changed, 12 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/e76b5636/ambari-server/src/main/java/org/apache/ambari/server/orm/DBAccessorImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/DBAccessorImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/orm/DBAccessorImpl.java
index faa58f2..d36367d 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/DBAccessorImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/DBAccessorImpl.java
@@ -956,8 +956,12 @@ public class DBAccessorImpl implements DBAccessor {
 
   @Override
   public void dropTable(String tableName) throws SQLException {
-    String query = dbmsHelper.getDropTableStatement(tableName);
-    executeQuery(query);
+    if (tableExists(tableName)){
+      String query = dbmsHelper.getDropTableStatement(tableName);
+      executeQuery(query);
+    } else {
+      LOG.warn("{} table doesn't exists, skipping", tableName);
+    }
   }
 
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/e76b5636/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 71a0ff3..ffcf668 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
@@ -156,6 +156,8 @@ public class UpgradeCatalog260 extends AbstractUpgradeCatalog {
   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";
+  public static final String FK_UPGRADE_FROM_REPO_VERSION_ID = "FK_upgrade_from_repo_version_id";
+  public static final String FK_UPGRADE_TO_REPO_VERSION_ID = "FK_upgrade_to_repo_version_id";
 
 
   /**
@@ -213,8 +215,12 @@ public class UpgradeCatalog260 extends AbstractUpgradeCatalog {
    * {@value #FK_SERVICEDESIREDSTATE_DESIRED_STACK_ID}
    * {@value #FK_HOSTCOMPONENTDESIREDSTATE_DESIRED_STACK_ID}
    * {@value #FK_HOSTCOMPONENTSTATE_CURRENT_STACK_ID}
+   * {@value #FK_UPGRADE_FROM_REPO_VERSION_ID}
+   * {@value #FK_UPGRADE_TO_REPO_VERSION_ID}
    */
   private void dropBrokenFK() throws SQLException {
+    dbAccessor.dropFKConstraint(UPGRADE_TABLE, FK_UPGRADE_FROM_REPO_VERSION_ID);
+    dbAccessor.dropFKConstraint(UPGRADE_TABLE, FK_UPGRADE_TO_REPO_VERSION_ID);
     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);