You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by ac...@apache.org on 2020/07/10 00:59:29 UTC

[phoenix] branch 4.x updated: PHOENIX-5995 Index Rebuild page size is not honored in case of point deletes

This is an automated email from the ASF dual-hosted git repository.

achouhan pushed a commit to branch 4.x
in repository https://gitbox.apache.org/repos/asf/phoenix.git


The following commit(s) were added to refs/heads/4.x by this push:
     new a1dbaa8  PHOENIX-5995 Index Rebuild page size is not honored in case of point deletes
a1dbaa8 is described below

commit a1dbaa874693ac0e3bf63f79171477cf0612f109
Author: Abhishek Singh Chouhan <ab...@salesforce.com>
AuthorDate: Wed Jul 8 20:33:55 2020 -0700

    PHOENIX-5995 Index Rebuild page size is not honored in case of point deletes
---
 .../end2end/IndexToolForNonTxGlobalIndexIT.java    | 47 ++++++++++++++++++++++
 .../coprocessor/IndexRebuildRegionScanner.java     |  3 +-
 2 files changed, 49 insertions(+), 1 deletion(-)

diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/IndexToolForNonTxGlobalIndexIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/IndexToolForNonTxGlobalIndexIT.java
index 11c785c..527dc87 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/IndexToolForNonTxGlobalIndexIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/IndexToolForNonTxGlobalIndexIT.java
@@ -1130,6 +1130,53 @@ public class IndexToolForNonTxGlobalIndexIT extends BaseUniqueNamesOwnClusterIT
     }
 
     @Test
+    public void testPointDeleteRebuildWithPageSize() throws Exception {
+        String schemaName = generateUniqueName();
+        String dataTableName = generateUniqueName();
+        String fullDataTableName = SchemaUtil.getTableName(schemaName, dataTableName);
+        String indexTableName = generateUniqueName();
+        try (Connection conn = DriverManager.getConnection(getUrl())) {
+            conn.createStatement().execute(
+                "CREATE TABLE " + fullDataTableName + "(k VARCHAR PRIMARY KEY, v VARCHAR)");
+            conn.createStatement().execute("DELETE FROM " + fullDataTableName + " WHERE k = 'a'");
+            conn.createStatement().execute("DELETE FROM " + fullDataTableName + " WHERE k = 'b'");
+            conn.createStatement().execute("DELETE FROM " + fullDataTableName + " WHERE k = 'c'");
+            conn.commit();
+            conn.createStatement().execute(String.format("CREATE INDEX %s ON %s (v) ASYNC",
+                indexTableName, fullDataTableName));
+            // Run the index MR job and verify that the index table is built correctly
+            Configuration conf = new Configuration(getUtility().getConfiguration());
+            conf.set(QueryServices.INDEX_REBUILD_PAGE_SIZE_IN_ROWS, Long.toString(1));
+            IndexTool indexTool =
+                    IndexToolIT.runIndexTool(conf, directApi, useSnapshot, schemaName,
+                        dataTableName, indexTableName, null, 0, IndexTool.IndexVerifyType.BEFORE,
+                        new String[0]);
+            assertEquals(3, indexTool.getJob().getCounters().findCounter(INPUT_RECORDS).getValue());
+            assertEquals(3,
+                indexTool.getJob().getCounters().findCounter(SCANNED_DATA_ROW_COUNT).getValue());
+            assertEquals(0,
+                indexTool.getJob().getCounters().findCounter(REBUILT_INDEX_ROW_COUNT).getValue());
+            assertEquals(0, indexTool.getJob().getCounters()
+                    .findCounter(BEFORE_REBUILD_VALID_INDEX_ROW_COUNT).getValue());
+            assertEquals(0, indexTool.getJob().getCounters()
+                    .findCounter(BEFORE_REBUILD_EXPIRED_INDEX_ROW_COUNT).getValue());
+            assertEquals(0, indexTool.getJob().getCounters()
+                    .findCounter(BEFORE_REBUILD_INVALID_INDEX_ROW_COUNT).getValue());
+            assertEquals(0, indexTool.getJob().getCounters()
+                    .findCounter(BEFORE_REBUILD_MISSING_INDEX_ROW_COUNT).getValue());
+            assertEquals(0,
+                indexTool.getJob().getCounters()
+                        .findCounter(BEFORE_REBUILD_BEYOND_MAXLOOKBACK_MISSING_INDEX_ROW_COUNT)
+                        .getValue());
+            assertEquals(0,
+                indexTool.getJob().getCounters()
+                        .findCounter(BEFORE_REBUILD_BEYOND_MAXLOOKBACK_INVALID_INDEX_ROW_COUNT)
+                        .getValue());
+        }
+    }
+
+
+    @Test
     public void testUpdatablePKFilterViewIndexRebuild() throws Exception {
         if (!mutable) {
             return;
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/IndexRebuildRegionScanner.java b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/IndexRebuildRegionScanner.java
index e2418ba..36a1426 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/IndexRebuildRegionScanner.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/IndexRebuildRegionScanner.java
@@ -1333,7 +1333,8 @@ public class IndexRebuildRegionScanner extends GlobalIndexRegionScanner {
                         indexMutationCount += prepareIndexMutations(put, del, indexKeyToMutationMap, mostRecentIndexRowKeys);
                         dataRowCount++;
                     }
-                } while (hasMore && indexMutationCount < pageSizeInRows);
+                } while (hasMore && indexMutationCount < pageSizeInRows
+                        && dataRowCount < pageSizeInRows);
                 if (!indexKeyToMutationMap.isEmpty()) {
                     if (indexRowKeyforReadRepair != null) {
                         rebuildIndexRows(indexKeyToMutationMap, Collections.EMPTY_LIST, verificationResult);