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 e5efffb4ed PHOENIX-7113 Create a feature flag for invoking MDEI#invalidateServerMetadataCache (#1753) e5efffb4ed is described below commit e5efffb4ed16f256d8c27552936a1725672c5fae Author: Rushabh Shah <shahr...@apache.org> AuthorDate: Wed Dec 13 09:12:04 2023 -0800 PHOENIX-7113 Create a feature flag for invoking MDEI#invalidateServerMetadataCache (#1753) --- .../apache/phoenix/end2end/InvalidateMetadataCacheIT.java | 2 ++ .../apache/phoenix/coprocessor/MetaDataEndpointImpl.java | 14 +++++++------- .../org/apache/phoenix/cache/ServerMetadataCacheTest.java | 2 ++ .../src/test/java/org/apache/phoenix/query/BaseTest.java | 7 ++----- 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/InvalidateMetadataCacheIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/InvalidateMetadataCacheIT.java index f399610a2e..c0727b9d68 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/InvalidateMetadataCacheIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/InvalidateMetadataCacheIT.java @@ -35,6 +35,7 @@ import java.util.Properties; import static org.apache.hadoop.hbase.coprocessor.CoprocessorHost.REGIONSERVER_COPROCESSOR_CONF_KEY; import static org.apache.phoenix.coprocessor.MetaDataEndpointImpl.PHOENIX_METADATA_CACHE_INVALIDATION_TIMEOUT_MS; +import static org.apache.phoenix.coprocessor.MetaDataEndpointImpl.PHOENIX_METADATA_INVALIDATE_CACHE_ENABLED; import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import static org.junit.Assert.fail; @@ -48,6 +49,7 @@ public class InvalidateMetadataCacheIT extends BaseTest { Map<String, String> props = Maps.newHashMapWithExpectedSize(1); // to fail fast in case of exception. props.put("hbase.client.retries.number", String.valueOf(0)); + props.put(PHOENIX_METADATA_INVALIDATE_CACHE_ENABLED, "true"); props.put(REGIONSERVER_COPROCESSOR_CONF_KEY, FailingPhoenixRegionServerEndpoint.class.getName()); // Setting phoenix metadata cache invalidation timeout to a small number to fail fast. diff --git a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java index d905f6ad5b..c9aa4acb73 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java @@ -18,7 +18,6 @@ package org.apache.phoenix.coprocessor; import static org.apache.hadoop.hbase.KeyValueUtil.createFirstOnRow; -import static org.apache.hadoop.hbase.coprocessor.CoprocessorHost.REGIONSERVER_COPROCESSOR_CONF_KEY; import static org.apache.phoenix.coprocessor.generated.MetaDataProtos.MutationCode.UNABLE_TO_CREATE_CHILD_LINK; import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.APPEND_ONLY_SCHEMA_BYTES; import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.ARRAY_SIZE_BYTES; @@ -333,6 +332,8 @@ public class MetaDataEndpointImpl extends MetaDataProtocol implements RegionCopr "phoenix.metadata.cache.invalidation.timeoutMs"; // Default to 10 seconds. public static final long PHOENIX_METADATA_CACHE_INVALIDATION_TIMEOUT_MS_DEFAULT = 10 * 1000; + public static final String PHOENIX_METADATA_INVALIDATE_CACHE_ENABLED = + "phoenix.metadata.invalidate.cache.enabled"; // KeyValues for Table private static final Cell TABLE_TYPE_KV = createFirstOnRow(ByteUtil.EMPTY_BYTE_ARRAY, TABLE_FAMILY_BYTES, TABLE_TYPE_BYTES); @@ -3490,12 +3491,11 @@ TABLE_FAMILY_BYTES, TABLE_SEQ_NUM_BYTES); private void invalidateServerMetadataCache(List<InvalidateServerMetadataCacheRequest> requests) throws Throwable { Configuration conf = env.getConfiguration(); - String value = conf.get(REGIONSERVER_COPROCESSOR_CONF_KEY); - if (value == null - || !value.contains(PhoenixRegionServerEndpoint.class.getName())) { - // PhoenixRegionServerEndpoint is not loaded. We don't have to invalidate the cache. - LOGGER.info("Skip invalidating server metadata cache since PhoenixRegionServerEndpoint" - + " is not loaded"); + boolean invalidateCacheEnabled = conf.getBoolean(PHOENIX_METADATA_INVALIDATE_CACHE_ENABLED, + false); + if (!invalidateCacheEnabled) { + LOGGER.info("Skip invalidating server metadata cache since conf property" + + " phoenix.metadata.invalidate.cache.enabled is set to false"); return; } metricsMetadataCachingSource.incrementMetadataCacheInvalidationOperationsCount(); diff --git a/phoenix-core/src/test/java/org/apache/phoenix/cache/ServerMetadataCacheTest.java b/phoenix-core/src/test/java/org/apache/phoenix/cache/ServerMetadataCacheTest.java index a210e40579..3ba83ff2ee 100644 --- a/phoenix-core/src/test/java/org/apache/phoenix/cache/ServerMetadataCacheTest.java +++ b/phoenix-core/src/test/java/org/apache/phoenix/cache/ServerMetadataCacheTest.java @@ -58,6 +58,7 @@ import java.util.Map; import java.util.Properties; import java.util.Random; +import static org.apache.phoenix.coprocessor.MetaDataEndpointImpl.PHOENIX_METADATA_INVALIDATE_CACHE_ENABLED; import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; @@ -80,6 +81,7 @@ public class ServerMetadataCacheTest extends ParallelStatsDisabledIT { public static synchronized void doSetup() throws Exception { Map<String, String> props = Maps.newHashMapWithExpectedSize(1); props.put(QueryServices.LAST_DDL_TIMESTAMP_VALIDATION_ENABLED, Boolean.toString(true)); + props.put(PHOENIX_METADATA_INVALIDATE_CACHE_ENABLED, Boolean.toString(true)); props.put(QueryServices.TASK_HANDLING_INTERVAL_MS_ATTRIB, Long.toString(Long.MAX_VALUE)); props.put(QueryServices.TASK_HANDLING_INITIAL_DELAY_MS_ATTRIB, diff --git a/phoenix-core/src/test/java/org/apache/phoenix/query/BaseTest.java b/phoenix-core/src/test/java/org/apache/phoenix/query/BaseTest.java index bbee8a8a5d..5389a2c613 100644 --- a/phoenix-core/src/test/java/org/apache/phoenix/query/BaseTest.java +++ b/phoenix-core/src/test/java/org/apache/phoenix/query/BaseTest.java @@ -650,16 +650,13 @@ public abstract class BaseTest { } /* - Set property hbase.coprocessor.regionserver.classes to include PhoenixRegionServerEndpoint - by default. If some other regionserver coprocs are already present then append - PhoenixRegionServerEndpoint to the existing coprocs. + Set property hbase.coprocessor.regionserver.classes to include PhoenixRegionServerEndpoint + by default, if some other regionserver coprocs are not already present. */ private static void setPhoenixRegionServerEndpoint(Configuration conf) { String value = conf.get(REGIONSERVER_COPROCESSOR_CONF_KEY); if (value == null) { value = PhoenixRegionServerEndpoint.class.getName(); - } else { - value = String.join(",", value, PhoenixRegionServerEndpoint.class.getName()); } conf.set(REGIONSERVER_COPROCESSOR_CONF_KEY, value); }