瀏覽代碼

AMBARI-12696 Server error was present when would have tried to add host (after upgrade secured cluster from 2.0.0 /1.7.0 to 2.1.1) (dsen)

Dmytro Sen 10 年之前
父節點
當前提交
43ea79baf6

+ 3 - 0
ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog211.java

@@ -230,6 +230,9 @@ public class UpgradeCatalog211 extends AbstractUpgradeCatalog {
     dbAccessor.alterColumn(HOST_COMPONENT_STATE_TABLE,
         new DBColumnInfo(HOST_COMPONENT_STATE_ID_COLUMN, Long.class, null, null, false));
 
+    // Add sequence for hostcomponentstate id
+    addSequence("hostcomponentstate_id_seq", id.get(), false);
+
     // drop the current PK
     String primaryKeyConstraintName = null;
     Configuration.DatabaseType databaseType = configuration.getDatabaseType();

+ 4 - 0
ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog211Test.java

@@ -18,6 +18,8 @@
 
 package org.apache.ambari.server.upgrade;
 
+import static org.easymock.EasyMock.anyBoolean;
+import static org.easymock.EasyMock.anyLong;
 import static org.easymock.EasyMock.anyObject;
 import static org.easymock.EasyMock.capture;
 import static org.easymock.EasyMock.expect;
@@ -86,6 +88,8 @@ public class UpgradeCatalog211Test extends EasyMockSupport {
       expectLastCall().andReturn(connection).anyTimes();
       connection.createStatement();
       expectLastCall().andReturn(statement).anyTimes();
+      statement.executeQuery("SELECT COUNT(*) from ambari_sequences where sequence_name='hostcomponentstate_id_seq'");
+      expectLastCall().andReturn(resultSet).atLeastOnce();
       statement.executeQuery(anyObject(String.class));
       expectLastCall().andReturn(resultSet).anyTimes();