You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by lp...@apache.org on 2017/09/12 10:04:30 UTC

[13/57] [abbrv] ambari git commit: AMBARI-21883. Upgrade to Ambari 2.6.0 fails with DB constraint violation on fk_sc_history_upgrade_id (dlysnichenko)

AMBARI-21883. Upgrade to Ambari 2.6.0 fails with DB constraint violation on fk_sc_history_upgrade_id (dlysnichenko)


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

Branch: refs/heads/feature-branch-AMBARI-21307
Commit: 0c45d48f5d82edbe096461c51832aa90d97593a4
Parents: 54d4d5e
Author: Lisnichenko Dmitro <dl...@hortonworks.com>
Authored: Wed Sep 6 20:05:32 2017 +0300
Committer: Lisnichenko Dmitro <dl...@hortonworks.com>
Committed: Wed Sep 6 20:06:05 2017 +0300

----------------------------------------------------------------------
 .../ambari/server/checks/DatabaseConsistencyCheckHelper.java   | 5 ++++-
 .../org/apache/ambari/server/upgrade/UpgradeCatalog260.java    | 6 +++++-
 2 files changed, 9 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/0c45d48f/ambari-server/src/main/java/org/apache/ambari/server/checks/DatabaseConsistencyCheckHelper.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/checks/DatabaseConsistencyCheckHelper.java b/ambari-server/src/main/java/org/apache/ambari/server/checks/DatabaseConsistencyCheckHelper.java
index 6fef3b8..054c470 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/checks/DatabaseConsistencyCheckHelper.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/checks/DatabaseConsistencyCheckHelper.java
@@ -605,7 +605,7 @@ public class DatabaseConsistencyCheckHelper {
 
     Set<String> nonMappedConfigs = new HashSet<>();
     for (ClusterConfigEntity clusterConfigEntity : notMappedClasterConfigs) {
-      if (!clusterConfigEntity.isUnmapped()){
+      if (!clusterConfigEntity.isUnmapped()){ //this check does not report warning for configs from deleted services
         nonMappedConfigs.add(clusterConfigEntity.getType() + '-' + clusterConfigEntity.getTag());
       }
     }
@@ -619,6 +619,7 @@ public class DatabaseConsistencyCheckHelper {
   * of desired host component states. According to ambari logic these
   * two tables should have the same count of rows. If not then we are
   * adding missed host components.
+  * hard to predict root couse of inconsistency, so it can be dangerous
   */
   @Transactional
   static void fixHostComponentStatesCountEqualsHostComponentsDesiredStates() {
@@ -692,6 +693,7 @@ public class DatabaseConsistencyCheckHelper {
    * The purpose of these checks is to avoid that tables and constraints in ambari's schema get confused with tables
    * and constraints in other schemas on the DB user's search path. This can happen after an improperly made DB restore
    * operation and can cause issues during upgrade.
+   * we may have no permissions (e.g. external DB) to auto fix this problem
   **/
   static void checkSchemaName () {
     Configuration conf = injector.getInstance(Configuration.class);
@@ -747,6 +749,7 @@ public class DatabaseConsistencyCheckHelper {
 
   /**
   * This method checks tables engine type to be innodb for MySQL.
+  * it's too risky to autofix by migrating DB to innodb
   * */
   static void checkMySQLEngine () {
     Configuration conf = injector.getInstance(Configuration.class);

http://git-wip-us.apache.org/repos/asf/ambari/blob/0c45d48f/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 de5d5ae..665b350 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
@@ -88,6 +88,8 @@ public class UpgradeCatalog260 extends AbstractUpgradeCatalog {
   public static final String FK_REPO_VERSION_ID = "FK_repo_version_id";
 
   public static final String UPGRADE_TABLE = "upgrade";
+  public static final String UPGRADE_GROUP_TABLE = "upgrade_group";
+  public static final String UPGRADE_ITEM_TABLE = "upgrade_item";
   public static final String FROM_REPO_VERSION_ID_COLUMN = "from_repo_version_id";
   public static final String TO_REPO_VERSION_ID_COLUMN = "to_repo_version_id";
   public static final String ORCHESTRATION_COLUMN = "orchestration";
@@ -159,9 +161,9 @@ public class UpgradeCatalog260 extends AbstractUpgradeCatalog {
     addSelectedCollumsToClusterconfigTable();
     updateHostComponentDesiredStateTable();
     updateHostComponentStateTable();
+    dropStaleTables();
     updateUpgradeTable();
     createUpgradeHistoryTable();
-    dropStaleTables();
     updateRepositoryVersionTable();
     renameServiceDeletedColumn();
   }
@@ -231,6 +233,8 @@ public class UpgradeCatalog260 extends AbstractUpgradeCatalog {
    * @throws java.sql.SQLException
    */
   private void updateUpgradeTable() throws SQLException {
+    dbAccessor.clearTable(UPGRADE_ITEM_TABLE);
+    dbAccessor.clearTable(UPGRADE_GROUP_TABLE);
     dbAccessor.clearTable(UPGRADE_TABLE);
     dbAccessor.dropFKConstraint(UPGRADE_TABLE, FK_UPGRADE_FROM_REPO_ID);
     dbAccessor.dropFKConstraint(UPGRADE_TABLE, FK_UPGRADE_TO_REPO_ID);