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

shahrs87 pushed a commit to branch PHOENIX-6883-feature
in repository https://gitbox.apache.org/repos/asf/phoenix.git


The following commit(s) were added to refs/heads/PHOENIX-6883-feature by this 
push:
     new 4d42c915e1 PHOENIX-7293 : New Update Cache Frequency config for 
Indexes in PENDING_DISABLE state (#1864)
4d42c915e1 is described below

commit 4d42c915e18c4f34f195826859f3d6fa86148cdc
Author: palash <palashc...@gmail.com>
AuthorDate: Thu Apr 4 10:38:16 2024 -0700

    PHOENIX-7293 : New Update Cache Frequency config for Indexes in 
PENDING_DISABLE state (#1864)
---
 .../main/java/org/apache/phoenix/query/QueryServices.java    |  4 ++++
 .../java/org/apache/phoenix/query/QueryServicesOptions.java  |  2 ++
 .../main/java/org/apache/phoenix/schema/MetaDataClient.java  | 12 +++++++++++-
 3 files changed, 17 insertions(+), 1 deletion(-)

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 82d354e285..ef2c182125 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
@@ -326,6 +326,10 @@ public interface QueryServices extends SQLCloseable {
     //Update Cache Frequency default config attribute
     public static final String DEFAULT_UPDATE_CACHE_FREQUENCY_ATRRIB  = 
"phoenix.default.update.cache.frequency";
 
+    //Update Cache Frequency for indexes in PENDING_DISABLE state
+    public static final String 
UPDATE_CACHE_FREQUENCY_FOR_PENDING_DISABLED_INDEX
+            = "phoenix.update.cache.frequency.pending.disable.index";
+
     // whether to validate last ddl timestamps during client operations
     public static final String LAST_DDL_TIMESTAMP_VALIDATION_ENABLED = 
"phoenix.ddl.timestamp.validation.enabled";
 
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 e24763e96c..1f55135c93 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
@@ -374,6 +374,8 @@ public class QueryServicesOptions {
     public static final long DEFAULT_UPDATE_CACHE_FREQUENCY = 0;
     public static final int DEFAULT_SMALL_SCAN_THRESHOLD = 100;
     public static final boolean DEFAULT_LAST_DDL_TIMESTAMP_VALIDATION_ENABLED 
= false;
+    public static final String 
DEFAULT_UPDATE_CACHE_FREQUENCY_FOR_PENDING_DISABLED_INDEX
+                                                                            = 
Long.toString(0L);
 
     // default system task handling interval in milliseconds
     public static final long DEFAULT_TASK_HANDLING_INTERVAL_MS = 60*1000; // 1 
min
diff --git 
a/phoenix-core-client/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
 
b/phoenix-core-client/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
index e9550fc482..40da589976 100644
--- 
a/phoenix-core-client/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
+++ 
b/phoenix-core-client/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
@@ -768,7 +768,17 @@ public class MetaDataClient {
             // What if the table is created with UPDATE_CACHE_FREQUENCY 
explicitly set to ALWAYS?
             // i.e. explicitly set to 0. We should ideally be checking for 
something like
             // hasUpdateCacheFrequency().
-            if (table.getUpdateCacheFrequency() != 0L) {
+            //always fetch an Index in PENDING_DISABLE state to retrieve 
server timestamp
+            //QueryOptimizer needs that to decide whether the index can be used
+            if (PIndexState.PENDING_DISABLE.equals(table.getIndexState())) {
+                effectiveUpdateCacheFreq =
+                        (Long) 
ConnectionProperty.UPDATE_CACHE_FREQUENCY.getValue(
+                            connection.getQueryServices().getProps().get(
+                  
QueryServices.UPDATE_CACHE_FREQUENCY_FOR_PENDING_DISABLED_INDEX,
+                  
QueryServicesOptions.DEFAULT_UPDATE_CACHE_FREQUENCY_FOR_PENDING_DISABLED_INDEX));
+                ucfInfoForLogging = "pending-disable-index-level";
+            } else if (table.getUpdateCacheFrequency()
+                    != QueryServicesOptions.DEFAULT_UPDATE_CACHE_FREQUENCY) {
                 effectiveUpdateCacheFreq = table.getUpdateCacheFrequency();
                 ucfInfoForLogging = "table-level";
             } else {

Reply via email to