You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@phoenix.apache.org by GitBox <gi...@apache.org> on 2020/02/13 20:16:03 UTC

[GitHub] [phoenix] kadirozde commented on a change in pull request #705: PHOENIX-5723 PhoenixIndexImportDirectReducer cleanup method updates i…

kadirozde commented on a change in pull request #705: PHOENIX-5723 PhoenixIndexImportDirectReducer cleanup method updates i…
URL: https://github.com/apache/phoenix/pull/705#discussion_r379095085
 
 

 ##########
 File path: phoenix-core/src/it/java/org/apache/phoenix/end2end/IndexExtendedIT.java
 ##########
 @@ -314,4 +315,48 @@ public void testBuildDisabledIndex() throws Exception {
             conn.close();
         }
     }
+
+    @Test
+    public void testIndexStateOnException() throws Exception {
+        if (localIndex  || useSnapshot || useViewIndex) {
+            return;
+        }
+
+        String schemaName = generateUniqueName();
+        String dataTableName = generateUniqueName();
+        String dataTableFullName = SchemaUtil.getTableName(schemaName, dataTableName);
+        String indexTableName = generateUniqueName();
+        String indexFullName = SchemaUtil.getTableName(schemaName, indexTableName);
+        Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
+        try (Connection conn = DriverManager.getConnection(getUrl(), props)){
+            Statement stmt = conn.createStatement();
+            stmt.execute(String.format(
+                    "CREATE TABLE %s (ID INTEGER NOT NULL PRIMARY KEY, NAME VARCHAR, ZIP INTEGER) %s",
+                    dataTableFullName, tableDDLOptions));
+
+            stmt.execute(String.format(
+                    "UPSERT INTO %s VALUES(1, 'Phoenix', 12345)", dataTableFullName));
+
+            conn.commit();
+
+            // Configure IndexRegionObserver to fail the first write phase. This should not
+            // lead to any change on index and thus index verify during index rebuild should fail
+            IndexRegionObserver.setIgnoreIndexRebuildForTesting(true);
+            stmt.execute(String.format(
+                    "CREATE INDEX %s ON %s (NAME) INCLUDE (ZIP) ASYNC",
+                    indexTableName, dataTableFullName));
+
+            // Verify that the index table is not in the ACTIVE state
+            assertFalse(checkIndexState(conn, indexFullName, PIndexState.ACTIVE, 0L));
+
+            // Run the index MR job and verify that the index table rebuild fails
+            IndexToolIT.runIndexTool(true, false, schemaName, dataTableName,
+                    indexTableName, null, -1, IndexTool.IndexVerifyType.AFTER);
+
+            IndexRegionObserver.setIgnoreIndexRebuildForTesting(false);
+
+            // job failed, verify that the index table is still not in the ACTIVE state
+            assertFalse(checkIndexState(conn, indexFullName, PIndexState.ACTIVE, 0L));
 
 Review comment:
   @tkhurana, here just repeat the index tool run with // Run the index MR job and verify that the index table rebuild fails
               IndexToolIT.runIndexTool(true, false, schemaName, dataTableName,
                       indexTableName, null, 0, IndexTool.IndexVerifyType.AFTER); and then check the state : assertTrue(checkIndexState(conn, indexFullName, PIndexState.ACTIVE, 0L));

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services