You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by gj...@apache.org on 2020/04/30 18:20:33 UTC

[phoenix] branch 4.x updated: PHOENIX-5878 - IndexTool should not fail jobs when the only errors are due to rows out of MaxLookback

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

gjacoby 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 ed4310a  PHOENIX-5878 - IndexTool should not fail jobs when the only errors are due to rows out of MaxLookback
ed4310a is described below

commit ed4310aeba896a61595254d29e861f94780827e5
Author: Geoffrey Jacoby <gj...@apache.org>
AuthorDate: Wed Apr 29 14:00:55 2020 -0700

    PHOENIX-5878 - IndexTool should not fail jobs when the only errors are due to rows out of MaxLookback
---
 .../coprocessor/IndexToolVerificationResult.java   |  6 +-
 .../index/IndexToolVerificationResultTest.java     | 79 ++++++++++++++++++++++
 2 files changed, 82 insertions(+), 3 deletions(-)

diff --git a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/IndexToolVerificationResult.java b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/IndexToolVerificationResult.java
index a2d9145..06b8ff4 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/IndexToolVerificationResult.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/IndexToolVerificationResult.java
@@ -21,7 +21,6 @@ import org.apache.hadoop.hbase.Cell;
 import org.apache.hadoop.hbase.CellUtil;
 import org.apache.hadoop.hbase.client.Scan;
 import org.apache.hadoop.hbase.util.Bytes;
-import org.apache.phoenix.mapreduce.index.IndexTool;
 
 import static org.apache.phoenix.mapreduce.index.IndexVerificationResultRepository.AFTER_REBUILD_BEYOND_MAXLOOKBACK_INVALID_INDEX_ROW_COUNT_BYTES;
 import static org.apache.phoenix.mapreduce.index.IndexVerificationResultRepository.AFTER_REBUILD_BEYOND_MAXLOOKBACK_MISSING_INDEX_ROW_COUNT_BYTES;
@@ -480,8 +479,9 @@ public class IndexToolVerificationResult {
     }
 
     public boolean isVerificationFailed() {
-        if (getAfter().getInvalidIndexRowCount() + getAfter().getMissingIndexRowCount() +
-                getAfter().getBeyondMaxLookBackInvalidIndexRowCount() + getAfter().getBeyondMaxLookBackMissingIndexRowCount() > 0) {
+        //we don't want to count max look back failures alone as failing an index rebuild job
+        //so we omit them from the below calculation.
+        if (getAfter().getInvalidIndexRowCount() + getAfter().getMissingIndexRowCount() > 0) {
             return true;
         }
         return false;
diff --git a/phoenix-core/src/test/java/org/apache/phoenix/index/IndexToolVerificationResultTest.java b/phoenix-core/src/test/java/org/apache/phoenix/index/IndexToolVerificationResultTest.java
new file mode 100644
index 0000000..e195b53
--- /dev/null
+++ b/phoenix-core/src/test/java/org/apache/phoenix/index/IndexToolVerificationResultTest.java
@@ -0,0 +1,79 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.phoenix.index;
+
+import org.apache.phoenix.coprocessor.IndexToolVerificationResult;
+import org.junit.Test;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+public class IndexToolVerificationResultTest {
+    private long scanMaxTs = 0L;
+    @Test
+    public void testVerificationResultFailsWithMissing(){
+        IndexToolVerificationResult result = new IndexToolVerificationResult(scanMaxTs);
+        IndexToolVerificationResult.PhaseResult afterResult =
+            new IndexToolVerificationResult.PhaseResult();
+        afterResult.setValidIndexRowCount(1L);
+        afterResult.setMissingIndexRowCount(1L);
+        result.setAfter(afterResult);
+        assertTrue(result.isVerificationFailed());
+    }
+
+    @Test
+    public void testVerificationResultFailsWithInvalid(){
+        IndexToolVerificationResult result = new IndexToolVerificationResult(scanMaxTs);
+        IndexToolVerificationResult.PhaseResult afterResult =
+            new IndexToolVerificationResult.PhaseResult();
+        afterResult.setValidIndexRowCount(1L);
+        afterResult.setInvalidIndexRowCount(1L);
+        result.setAfter(afterResult);
+        assertTrue(result.isVerificationFailed());
+    }
+
+    @Test
+    public void testVerificationResultPassesWithJustBeyondMaxLookback(){
+        IndexToolVerificationResult result = new IndexToolVerificationResult(scanMaxTs);
+        IndexToolVerificationResult.PhaseResult afterResult =
+            new IndexToolVerificationResult.PhaseResult();
+        afterResult.setValidIndexRowCount(1L);
+        afterResult.setBeyondMaxLookBackInvalidIndexRowCount(1L);
+        afterResult.setBeyondMaxLookBackMissingIndexRowCount(1L);
+        result.setAfter(afterResult);
+        assertFalse(result.isVerificationFailed());
+    }
+
+    @Test
+    public void testVerificationResultDoesntFailWithBeforeErrors(){
+        IndexToolVerificationResult result = new IndexToolVerificationResult(scanMaxTs);
+        IndexToolVerificationResult.PhaseResult beforeResult =
+            new IndexToolVerificationResult.PhaseResult();
+        beforeResult.setValidIndexRowCount(1L);
+        beforeResult.setInvalidIndexRowCount(1L);
+        beforeResult.setMissingIndexRowCount(1L);
+        IndexToolVerificationResult.PhaseResult afterResult =
+            new IndexToolVerificationResult.PhaseResult();
+        afterResult.setValidIndexRowCount(3L);
+        result.setBefore(beforeResult);
+        result.setAfter(afterResult);
+        assertFalse(result.isVerificationFailed());
+    }
+
+}