You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by ka...@apache.org on 2019/12/19 19:58:42 UTC

[phoenix] branch 4.x-HBase-1.5 updated: PHOENIX-5640 Pending disable count should not be increased for rebuild write failures

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

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


The following commit(s) were added to refs/heads/4.x-HBase-1.5 by this push:
     new 782effc  PHOENIX-5640 Pending disable count should not be increased for rebuild write failures
782effc is described below

commit 782effcb15d2f27d7339b0de5a8c39dc405c4354
Author: Kadir <ko...@salesforce.com>
AuthorDate: Wed Dec 18 22:10:00 2019 -0800

    PHOENIX-5640 Pending disable count should not be increased for rebuild write failures
---
 .../end2end/index/MutableIndexRebuilderIT.java     |  5 +++++
 .../phoenix/index/PhoenixIndexFailurePolicy.java   |  5 ++++-
 .../java/org/apache/phoenix/util/TestUtil.java     | 22 ++++++++++++++++++++++
 3 files changed, 31 insertions(+), 1 deletion(-)

diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/MutableIndexRebuilderIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/MutableIndexRebuilderIT.java
index 55582b5..716a662 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/MutableIndexRebuilderIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/MutableIndexRebuilderIT.java
@@ -112,6 +112,8 @@ public class MutableIndexRebuilderIT extends BaseUniqueNamesOwnClusterIT {
             // Simulate write failure when rebuilder runs
             TestUtil.addCoprocessor(conn, fullIndexName, WriteFailingRegionObserver.class);
             waitForIndexState(conn, fullTableName, fullIndexName, PIndexState.INACTIVE);
+            long pendingDisableCount = TestUtil.getPendingDisableCount(
+                    conn.unwrap(PhoenixConnection.class), fullIndexName);
             // rebuild writes should retry for exactly the configured number of times
             ExecutorService executor = Executors.newSingleThreadExecutor();
             try {
@@ -123,6 +125,9 @@ public class MutableIndexRebuilderIT extends BaseUniqueNamesOwnClusterIT {
                     }});
                 assertTrue(future.get(120, TimeUnit.SECONDS));
                 assertEquals(numberOfRetries, WriteFailingRegionObserver.attempts.get());
+                // Index rebuild write failures should not increase the pending disable count of the index table
+                assertEquals(pendingDisableCount, TestUtil.getPendingDisableCount(
+                        conn.unwrap(PhoenixConnection.class), fullIndexName));
             } finally {
                 executor.shutdownNow();
             }
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/index/PhoenixIndexFailurePolicy.java b/phoenix-core/src/main/java/org/apache/phoenix/index/PhoenixIndexFailurePolicy.java
index 7ca3d5b..4d736a2 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/index/PhoenixIndexFailurePolicy.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/index/PhoenixIndexFailurePolicy.java
@@ -467,7 +467,10 @@ public class PhoenixIndexFailurePolicy extends DelegateIndexFailurePolicy {
     public static void doBatchWithRetries(MutateCommand mutateCommand,
             IndexWriteException iwe, PhoenixConnection connection, ReadOnlyProps config)
             throws IOException {
-        incrementPendingDisableCounter(iwe, connection);
+        if (!PhoenixIndexMetaData.isIndexRebuild(
+                mutateCommand.getMutationList().get(0).getAttributesMap())) {
+            incrementPendingDisableCounter(iwe, connection);
+        }
         int maxTries = config.getInt(HConstants.HBASE_CLIENT_RETRIES_NUMBER,
             HConstants.DEFAULT_HBASE_CLIENT_RETRIES_NUMBER);
         long pause = config.getLong(HConstants.HBASE_CLIENT_PAUSE,
diff --git a/phoenix-core/src/test/java/org/apache/phoenix/util/TestUtil.java b/phoenix-core/src/test/java/org/apache/phoenix/util/TestUtil.java
index 5662e4c..d22971d 100644
--- a/phoenix-core/src/test/java/org/apache/phoenix/util/TestUtil.java
+++ b/phoenix-core/src/test/java/org/apache/phoenix/util/TestUtil.java
@@ -17,6 +17,7 @@
  */
 package org.apache.phoenix.util;
 
+import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.TABLE_FAMILY_BYTES;
 import static org.apache.phoenix.query.BaseTest.generateUniqueName;
 import static org.apache.phoenix.query.QueryConstants.MILLIS_IN_DAY;
 import static org.apache.phoenix.query.QueryConstants.SINGLE_COLUMN_FAMILY_NAME;
@@ -57,6 +58,7 @@ import org.apache.hadoop.hbase.CellScanner;
 import org.apache.hadoop.hbase.HConstants;
 import org.apache.hadoop.hbase.HTableDescriptor;
 import org.apache.hadoop.hbase.client.Delete;
+import org.apache.hadoop.hbase.client.Get;
 import org.apache.hadoop.hbase.client.HBaseAdmin;
 import org.apache.hadoop.hbase.client.HTableInterface;
 import org.apache.hadoop.hbase.client.Put;
@@ -1007,6 +1009,26 @@ public class TestUtil {
     	IndexStateCheck state = checkIndexStateInternal(conn, fullIndexName, null, null);
     	return state.indexState;
     }
+
+    public static long getPendingDisableCount(PhoenixConnection conn, String indexTableName) {
+        byte[] indexTableKey = SchemaUtil.getTableKeyFromFullName(indexTableName);
+        Get get = new Get(indexTableKey);
+        get.addColumn(TABLE_FAMILY_BYTES, PhoenixDatabaseMetaData.PENDING_DISABLE_COUNT_BYTES);
+
+        try {
+            Result pendingDisableCountResult =
+                    conn.getQueryServices()
+                            .getTable(SchemaUtil.getPhysicalTableName(
+                                    PhoenixDatabaseMetaData.SYSTEM_CATALOG_NAME,
+                                    conn.getQueryServices().getProps()).getName())
+                            .get(get);
+            return Bytes.toLong(pendingDisableCountResult.getValue(TABLE_FAMILY_BYTES,
+                    PhoenixDatabaseMetaData.PENDING_DISABLE_COUNT_BYTES));
+        } catch (Exception e) {
+            LOGGER.error("Exception in getPendingDisableCount: " + e);
+            return 0;
+        }
+    }
     
     private static IndexStateCheck checkIndexStateInternal(Connection conn, String fullIndexName, PIndexState expectedIndexState, Long expectedIndexDisableTimestamp) throws SQLException {
         String schema = SchemaUtil.getSchemaNameFromFullName(fullIndexName);