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 20:55:00 UTC
[phoenix] branch master 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 master
in repository https://gitbox.apache.org/repos/asf/phoenix.git
The following commit(s) were added to refs/heads/master by this push:
new 4f6d8eb PHOENIX-5640 Pending disable count should not be increased for rebuild write failures
4f6d8eb is described below
commit 4f6d8eb8adccb763b0211a50f6a90e28cc497061
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 | 24 ++++++++++++++++++++++
3 files changed, 33 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 5f27eb9..fcccf43 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
@@ -111,6 +111,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 {
@@ -122,6 +124,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 6fdcc67..44ec6e0 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 c78067b..fb24ae5 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;
@@ -58,6 +59,9 @@ import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.Admin;
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.Put;
import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.client.ResultScanner;
@@ -1008,6 +1012,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);