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

vjasani pushed a commit to branch 5.2
in repository https://gitbox.apache.org/repos/asf/phoenix.git


The following commit(s) were added to refs/heads/5.2 by this push:
     new 9b3359d2dc PHOENIX-7230 : Optimize rpc call to master if all indexes 
are migrated to new coprocs (#1833)
9b3359d2dc is described below

commit 9b3359d2dcf3ffd912d82ae24ef4e6e607ef8ada
Author: palash <[email protected]>
AuthorDate: Fri Feb 23 15:54:06 2024 -0800

    PHOENIX-7230 : Optimize rpc call to master if all indexes are migrated to 
new coprocs (#1833)
    
    Co-authored-by: Palash Chauhan 
<[email protected]>
---
 .../java/org/apache/phoenix/execute/MutationState.java    | 15 ++++++++++++---
 .../main/java/org/apache/phoenix/query/QueryServices.java |  2 ++
 .../org/apache/phoenix/query/QueryServicesOptions.java    |  2 ++
 3 files changed, 16 insertions(+), 3 deletions(-)

diff --git 
a/phoenix-core-client/src/main/java/org/apache/phoenix/execute/MutationState.java
 
b/phoenix-core-client/src/main/java/org/apache/phoenix/execute/MutationState.java
index 834365452b..31e4d0bac0 100644
--- 
a/phoenix-core-client/src/main/java/org/apache/phoenix/execute/MutationState.java
+++ 
b/phoenix-core-client/src/main/java/org/apache/phoenix/execute/MutationState.java
@@ -22,7 +22,9 @@ import static 
org.apache.phoenix.monitoring.MetricType.DELETE_AGGREGATE_SUCCESS_
 import static 
org.apache.phoenix.monitoring.MetricType.UPSERT_AGGREGATE_FAILURE_SQL_COUNTER;
 import static 
org.apache.phoenix.monitoring.MetricType.UPSERT_AGGREGATE_SUCCESS_SQL_COUNTER;
 import static 
org.apache.phoenix.monitoring.MetricType.NUM_METADATA_LOOKUP_FAILURES;
+import static 
org.apache.phoenix.query.QueryServices.INDEX_REGION_OBSERVER_ENABLED_ALL_TABLES_ATTRIB;
 import static org.apache.phoenix.query.QueryServices.SOURCE_OPERATION_ATTRIB;
+import static 
org.apache.phoenix.query.QueryServicesOptions.DEFAULT_INDEX_REGION_OBSERVER_ENABLED_ALL_TABLES;
 import static 
org.apache.phoenix.thirdparty.com.google.common.base.Preconditions.checkNotNull;
 import static 
org.apache.phoenix.monitoring.GlobalClientMetrics.GLOBAL_MUTATION_BATCH_FAILED_COUNT;
 import static 
org.apache.phoenix.monitoring.GlobalClientMetrics.GLOBAL_MUTATION_BATCH_SIZE;
@@ -169,6 +171,8 @@ public class MutationState implements SQLCloseable {
     private static boolean allUpsertsMutations = true;
     private static boolean allDeletesMutations = true;
 
+    private final boolean indexRegionObserverEnabledAllTables;
+
     public static void resetAllMutationState(){
         allDeletesMutations = true;
         allUpsertsMutations = true;
@@ -228,6 +232,10 @@ public class MutationState implements SQLCloseable {
             isExternalTxContext = true;
             phoenixTransactionContext = 
txContext.newTransactionContext(txContext, subTask);
         }
+        this.indexRegionObserverEnabledAllTables = Boolean.parseBoolean(
+                this.connection.getQueryServices().getConfiguration().get(
+                    INDEX_REGION_OBSERVER_ENABLED_ALL_TABLES_ATTRIB,
+                    DEFAULT_INDEX_REGION_OBSERVER_ENABLED_ALL_TABLES));
     }
 
     public MutationState(TableRef table, MultiRowMutationState mutations, long 
sizeOffset,
@@ -1708,9 +1716,10 @@ public class MutationState implements SQLCloseable {
                 continue;
             }
             PTable logicalTable = tableInfo.getPTable();
-            if (tableInfo.getOrigTableRef().getTable().isImmutableRows()
-                    && IndexUtil.isGlobalIndexCheckerEnabled(connection,
-                    tableInfo.getHTableName())) {
+            if (tableInfo.getOrigTableRef().getTable().isImmutableRows() &&
+                (this.indexRegionObserverEnabledAllTables ||
+                 IndexUtil.isGlobalIndexCheckerEnabled(connection, 
tableInfo.getHTableName()))
+            ) {
 
                 byte[] emptyCF = SchemaUtil.getEmptyColumnFamily(logicalTable);
                 byte[] emptyCQ = 
EncodedColumnsUtil.getEmptyKeyValueInfo(logicalTable).getFirst();
diff --git 
a/phoenix-core-client/src/main/java/org/apache/phoenix/query/QueryServices.java 
b/phoenix-core-client/src/main/java/org/apache/phoenix/query/QueryServices.java
index 799bf8f7ce..16af7cb5ef 100644
--- 
a/phoenix-core-client/src/main/java/org/apache/phoenix/query/QueryServices.java
+++ 
b/phoenix-core-client/src/main/java/org/apache/phoenix/query/QueryServices.java
@@ -347,6 +347,8 @@ public interface QueryServices extends SQLCloseable {
     public static final String 
GLOBAL_INDEX_ROW_AGE_THRESHOLD_TO_DELETE_MS_ATTRIB = 
"phoenix.global.index.row.age.threshold.to.delete.ms";
     // Enable the IndexRegionObserver Coprocessor
     public static final String INDEX_REGION_OBSERVER_ENABLED_ATTRIB = 
"phoenix.index.region.observer.enabled";
+    // Whether IndexRegionObserver/GlobalIndexChecker is enabled for all tables
+    public static final String INDEX_REGION_OBSERVER_ENABLED_ALL_TABLES_ATTRIB 
= "phoenix.index.region.observer.enabled.all.tables";
     // Enable Phoenix server paging
     public static final String PHOENIX_SERVER_PAGING_ENABLED_ATTRIB = 
"phoenix.server.paging.enabled";
     // Enable support for long view index(default is false)
diff --git 
a/phoenix-core-client/src/main/java/org/apache/phoenix/query/QueryServicesOptions.java
 
b/phoenix-core-client/src/main/java/org/apache/phoenix/query/QueryServicesOptions.java
index 2d8d796a4f..3dac05b8cd 100644
--- 
a/phoenix-core-client/src/main/java/org/apache/phoenix/query/QueryServicesOptions.java
+++ 
b/phoenix-core-client/src/main/java/org/apache/phoenix/query/QueryServicesOptions.java
@@ -379,6 +379,8 @@ public class QueryServicesOptions {
 
     public static final long 
DEFAULT_GLOBAL_INDEX_ROW_AGE_THRESHOLD_TO_DELETE_MS = 7*24*60*60*1000; /* 7 
days */
     public static final boolean DEFAULT_INDEX_REGION_OBSERVER_ENABLED = true;
+
+    public static final String 
DEFAULT_INDEX_REGION_OBSERVER_ENABLED_ALL_TABLES = Boolean.toString(true);
     public static final boolean DEFAULT_PHOENIX_SERVER_PAGING_ENABLED = true;
     public static final long DEFAULT_INDEX_REBUILD_PAGE_SIZE_IN_ROWS = 32 * 
1024;
     public static final long DEFAULT_INDEX_PAGE_SIZE_IN_ROWS = 32 * 1024;

Reply via email to