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

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


The following commit(s) were added to refs/heads/4.14-HBase-1.4 by this push:
     new a377491  PHOENIX-5640 Pending disable count should not be increased 
for rebuild write failures
a377491 is described below

commit a377491e34b30f42d582f9a1b5792cc14a3c1345
Author: Kadir <kozde...@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 49fb5fa..68a1ee6 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
@@ -465,7 +465,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 5bbdbc0..c1901cb 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;
@@ -56,6 +57,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;
@@ -983,6 +985,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);

Reply via email to