From 941e52975730545e5e378129295d51ac5501e889 Mon Sep 17 00:00:00 2001 From: Andrew Purtell Date: Mon, 29 Jun 2026 11:30:31 -0700 Subject: [PATCH 1/3] PHOENIX-7829 TaskRegionObserver.SelfHealingTask runs unexpectedly during tests Co-authored-by: Claude Opus 4.8[1m] --- .../phoenix/cache/ServerMetadataCacheIT.java | 2 -- .../end2end/BackwardCompatibilityIT.java | 2 -- .../org/apache/phoenix/end2end/Bson5IT.java | 2 ++ .../apache/phoenix/end2end/CDCStream2IT.java | 2 ++ .../org/apache/phoenix/end2end/CDCStreamIT.java | 2 -- .../end2end/MetadataGetTableReadLockIT.java | 3 --- .../end2end/MetadataServerConnectionsIT.java | 2 -- .../phoenix/end2end/ParallelStatsEnabledIT.java | 1 - .../phoenix/end2end/UCFWithDisabledIndexIT.java | 1 - ...UCFWithDisabledIndexWithDDLValidationIT.java | 1 - .../end2end/UCFWithServerMetadataIT.java | 1 - .../apache/phoenix/end2end/UpsertSelectIT.java | 4 ---- .../end2end/UpsertSelectWithRegionMovesIT.java | 4 ---- .../phoenix/end2end/VarBinaryEncoded2IT.java | 2 ++ .../VarBinaryEncodedIndexUpsertSelectIT.java | 2 ++ .../phoenix/end2end/index/IndexMetadataIT.java | 8 ++++++++ .../index/PartialSystemCatalogIndexIT.java | 4 ---- .../transform/TransformMonitorExtendedIT.java | 2 ++ .../monitoring/BasePhoenixMetricsIT.java | 2 -- .../phoenix/monitoring/IndexMetricsIT.java | 1 - .../phoenix/monitoring/MetadataMetricsIT.java | 1 - .../ConnectionQueryServicesMetricsIT.java | 2 -- .../apache/phoenix/query/MetaDataCachingIT.java | 11 ++++------- .../java/org/apache/phoenix/query/BaseTest.java | 4 ++++ .../java/org/apache/phoenix/util/TestUtil.java | 17 +++++++++++++++++ 25 files changed, 43 insertions(+), 40 deletions(-) diff --git a/phoenix-core/src/it/java/org/apache/phoenix/cache/ServerMetadataCacheIT.java b/phoenix-core/src/it/java/org/apache/phoenix/cache/ServerMetadataCacheIT.java index 5650728718c..1070ae8021b 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/cache/ServerMetadataCacheIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/cache/ServerMetadataCacheIT.java @@ -101,8 +101,6 @@ public static synchronized void doSetup() throws Exception { props.put(QueryServices.DEFAULT_UPDATE_CACHE_FREQUENCY_ATRRIB, "NEVER"); 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, Long.toString(Long.MAX_VALUE)); setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); assertEquals(1, getUtility().getHBaseCluster().getNumLiveRegionServers()); serverName = getUtility().getHBaseCluster().getRegionServer(0).getServerName(); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/BackwardCompatibilityIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/BackwardCompatibilityIT.java index a2487cd7789..e57766a05ab 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/BackwardCompatibilityIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/BackwardCompatibilityIT.java @@ -115,8 +115,6 @@ public static synchronized Collection data() throws Exception public synchronized void doSetup() throws Exception { tmpDir = System.getProperty("java.io.tmpdir"); conf = HBaseConfiguration.create(); - conf.set(QueryServices.TASK_HANDLING_INTERVAL_MS_ATTRIB, Long.toString(Long.MAX_VALUE)); - conf.set(QueryServices.TASK_HANDLING_INITIAL_DELAY_MS_ATTRIB, Long.toString(Long.MAX_VALUE)); hbaseTestUtil = new HBaseTestingUtility(conf); setUpConfigForMiniCluster(conf); conf.set(QueryServices.EXTRA_JDBC_ARGUMENTS_ATTRIB, diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/Bson5IT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/Bson5IT.java index eef800e4b59..c7abae1b2b1 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/Bson5IT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/Bson5IT.java @@ -81,6 +81,8 @@ public static synchronized void doSetup() throws Exception { props.put(QueryServices.USE_STATS_FOR_PARALLELIZATION, Boolean.toString(false)); props.put(INDEX_CDC_CONSUMER_RETRY_PAUSE_MS, Integer.toString(5)); props.put(PHOENIX_INDEX_CDC_MUTATION_SERIALIZE, Boolean.TRUE.toString()); + // Eventual indexes need the self-healing task. It enables the CDC stream that feeds them. + props.put(QueryServices.TASK_HANDLING_INITIAL_DELAY_MS_ATTRIB, Long.toString(1)); setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); } diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/CDCStream2IT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/CDCStream2IT.java index 0ba2ba2f062..fad5cd2f55c 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/CDCStream2IT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/CDCStream2IT.java @@ -55,6 +55,8 @@ public static synchronized void doSetup() throws Exception { Integer.toString(60 * 60)); // An hour props.put(QueryServices.USE_STATS_FOR_PARALLELIZATION, Boolean.toString(false)); props.put("hbase.coprocessor.master.classes", TestPhoenixMasterObserver.class.getName()); + // The self-healing task enables the CDC stream. These tests wait for that state. + props.put(QueryServices.TASK_HANDLING_INITIAL_DELAY_MS_ATTRIB, Long.toString(1)); setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); } diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/CDCStreamIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/CDCStreamIT.java index cb805bfcccc..74f6c4e0d70 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/CDCStreamIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/CDCStreamIT.java @@ -86,8 +86,6 @@ public static synchronized void doSetup() throws Exception { Map props = Maps.newHashMapWithExpectedSize(1); props.put(PHOENIX_MAX_LOOKBACK_AGE_CONF_KEY, Integer.toString(60 * 60)); // An hour props.put(QueryServices.USE_STATS_FOR_PARALLELIZATION, Boolean.toString(false)); - props.put(QueryServices.TASK_HANDLING_INTERVAL_MS_ATTRIB, Long.toString(Long.MAX_VALUE)); - props.put(QueryServices.TASK_HANDLING_INITIAL_DELAY_MS_ATTRIB, Long.toString(Long.MAX_VALUE)); props.put("hbase.coprocessor.master.classes", PhoenixMasterObserver.class.getName()); setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); taskRegionEnvironment = diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/MetadataGetTableReadLockIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/MetadataGetTableReadLockIT.java index 58c4b8fbc86..b2726c6350c 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/MetadataGetTableReadLockIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/MetadataGetTableReadLockIT.java @@ -29,7 +29,6 @@ import org.apache.hadoop.hbase.util.Bytes; import org.apache.phoenix.coprocessor.MetaDataEndpointImpl; import org.apache.phoenix.query.BaseTest; -import org.apache.phoenix.query.QueryServices; import org.apache.phoenix.util.ReadOnlyProps; import org.apache.phoenix.util.TestUtil; import org.junit.AfterClass; @@ -50,8 +49,6 @@ public class MetadataGetTableReadLockIT extends BaseTest { @BeforeClass public static synchronized void doSetup() throws Exception { Map props = Maps.newHashMapWithExpectedSize(1); - // Disable system task handling - props.put(QueryServices.TASK_HANDLING_INITIAL_DELAY_MS_ATTRIB, Long.toString(Long.MAX_VALUE)); setUpTestDriver(new ReadOnlyProps(props)); } diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/MetadataServerConnectionsIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/MetadataServerConnectionsIT.java index bebabc9bbfd..e07ad3c8b83 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/MetadataServerConnectionsIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/MetadataServerConnectionsIT.java @@ -52,7 +52,6 @@ import org.apache.phoenix.jdbc.PhoenixDatabaseMetaData; import org.apache.phoenix.protobuf.ProtobufUtil; import org.apache.phoenix.query.BaseTest; -import org.apache.phoenix.query.QueryServices; import org.apache.phoenix.util.ClientUtil; import org.apache.phoenix.util.MetaDataUtil; import org.apache.phoenix.util.ReadOnlyProps; @@ -80,7 +79,6 @@ public class MetadataServerConnectionsIT extends BaseTest { @BeforeClass public static synchronized void doSetup() throws Exception { Map props = Maps.newHashMapWithExpectedSize(1); - props.put(QueryServices.TASK_HANDLING_INITIAL_DELAY_MS_ATTRIB, Long.toString(Long.MAX_VALUE)); props.put(DISABLE_VIEW_SUBTREE_VALIDATION, "true"); props.put(PHOENIX_INDEX_CDC_CONSUMER_ENABLED, Boolean.toString(false)); setUpTestDriver(new ReadOnlyProps(props)); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ParallelStatsEnabledIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ParallelStatsEnabledIT.java index c82dbf1f1e3..095306c7ddd 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ParallelStatsEnabledIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ParallelStatsEnabledIT.java @@ -45,7 +45,6 @@ public static synchronized final void doSetup() throws Exception { props.put(QueryServices.STATS_UPDATE_FREQ_MS_ATTRIB, Long.toString(5)); props.put(QueryServices.MAX_SERVER_METADATA_CACHE_TIME_TO_LIVE_MS_ATTRIB, Long.toString(5)); props.put(QueryServices.USE_STATS_FOR_PARALLELIZATION, Boolean.toString(true)); - props.put(QueryServices.TASK_HANDLING_INITIAL_DELAY_MS_ATTRIB, Long.toString(Long.MAX_VALUE)); setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); TaskRegionEnvironment = diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/UCFWithDisabledIndexIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/UCFWithDisabledIndexIT.java index 50d35d5cbda..7163c944f29 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/UCFWithDisabledIndexIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/UCFWithDisabledIndexIT.java @@ -75,7 +75,6 @@ private static void initCluster() throws Exception { props.put(QueryServices.DEFAULT_UPDATE_CACHE_FREQUENCY_ATRRIB, "ALWAYS"); props.put(QueryServices.LAST_DDL_TIMESTAMP_VALIDATION_ENABLED, Boolean.toString(false)); props.put(QueryServices.PHOENIX_METADATA_INVALIDATE_CACHE_ENABLED, Boolean.toString(false)); - props.put(QueryServices.TASK_HANDLING_INITIAL_DELAY_MS_ATTRIB, Long.toString(Long.MAX_VALUE)); props.put(DISABLE_VIEW_SUBTREE_VALIDATION, "true"); props.put(INDEX_USE_SERVER_METADATA_ATTRIB, Boolean.toString(false)); setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/UCFWithDisabledIndexWithDDLValidationIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/UCFWithDisabledIndexWithDDLValidationIT.java index 8c63fd90d81..44b703dc808 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/UCFWithDisabledIndexWithDDLValidationIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/UCFWithDisabledIndexWithDDLValidationIT.java @@ -44,7 +44,6 @@ private static void initCluster() throws Exception { props.put(QueryServices.DEFAULT_UPDATE_CACHE_FREQUENCY_ATRRIB, "NEVER"); props.put(QueryServices.LAST_DDL_TIMESTAMP_VALIDATION_ENABLED, Boolean.toString(true)); props.put(QueryServices.PHOENIX_METADATA_INVALIDATE_CACHE_ENABLED, Boolean.toString(true)); - props.put(QueryServices.TASK_HANDLING_INITIAL_DELAY_MS_ATTRIB, Long.toString(Long.MAX_VALUE)); props.put(INDEX_USE_SERVER_METADATA_ATTRIB, Boolean.toString(false)); setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); } diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/UCFWithServerMetadataIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/UCFWithServerMetadataIT.java index 62e68449311..a72122d466f 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/UCFWithServerMetadataIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/UCFWithServerMetadataIT.java @@ -107,7 +107,6 @@ public void addServerCache(RpcController controller, AddServerCacheRequest reque @BeforeClass public static synchronized void doSetup() throws Exception { Map props = new HashMap<>(1); - props.put(QueryServices.TASK_HANDLING_INITIAL_DELAY_MS_ATTRIB, Long.toString(Long.MAX_VALUE)); props.put(PHOENIX_INDEX_CDC_CONSUMER_ENABLED, Boolean.toString(false)); setUpTestDriver(new ReadOnlyProps(props)); } diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/UpsertSelectIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/UpsertSelectIT.java index 588d0d7eb06..4b572ee580d 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/UpsertSelectIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/UpsertSelectIT.java @@ -86,10 +86,6 @@ public static synchronized void doSetup() throws Exception { // An hour - inherited from ParallelStatsDisabledIT props.put(BaseScannerRegionObserverConstants.PHOENIX_MAX_LOOKBACK_AGE_CONF_KEY, Integer.toString(60 * 60)); - // Postpone scans of SYSTEM.TASK indefinitely so as to prevent - // any addition to GLOBAL_OPEN_PHOENIX_CONNECTIONS - props.put(QueryServices.TASK_HANDLING_INTERVAL_MS_ATTRIB, Long.toString(Long.MAX_VALUE)); - props.put(QueryServices.TASK_HANDLING_INITIAL_DELAY_MS_ATTRIB, Long.toString(Long.MAX_VALUE)); props.put(PHOENIX_INDEX_CDC_CONSUMER_ENABLED, Boolean.toString(false)); setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); } diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/UpsertSelectWithRegionMovesIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/UpsertSelectWithRegionMovesIT.java index 3098be41994..4042082941f 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/UpsertSelectWithRegionMovesIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/UpsertSelectWithRegionMovesIT.java @@ -87,10 +87,6 @@ public static synchronized void doSetup() throws Exception { // An hour - inherited from ParallelStatsDisabledIT props.put(BaseScannerRegionObserverConstants.PHOENIX_MAX_LOOKBACK_AGE_CONF_KEY, Integer.toString(60 * 60)); - // Postpone scans of SYSTEM.TASK indefinitely so as to prevent - // any addition to GLOBAL_OPEN_PHOENIX_CONNECTIONS - props.put(QueryServices.TASK_HANDLING_INTERVAL_MS_ATTRIB, Long.toString(Long.MAX_VALUE)); - props.put(QueryServices.TASK_HANDLING_INITIAL_DELAY_MS_ATTRIB, Long.toString(Long.MAX_VALUE)); props.put(QueryServices.PHOENIX_SERVER_PAGE_SIZE_MS, Long.toString(0)); props.put(QueryServices.TESTS_MINI_CLUSTER_NUM_REGION_SERVERS, String.valueOf(2)); props.put(HConstants.HBASE_CLIENT_SCANNER_MAX_RESULT_SIZE_KEY, String.valueOf(1)); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/VarBinaryEncoded2IT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/VarBinaryEncoded2IT.java index 5a0e5e4407f..f6affa9555c 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/VarBinaryEncoded2IT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/VarBinaryEncoded2IT.java @@ -75,6 +75,8 @@ public static synchronized void doSetup() throws Exception { props.put(QueryServices.USE_STATS_FOR_PARALLELIZATION, Boolean.toString(false)); props.put(INDEX_CDC_CONSUMER_RETRY_PAUSE_MS, Integer.toString(5)); props.put(PHOENIX_INDEX_CDC_MUTATION_SERIALIZE, Boolean.FALSE.toString()); + // Eventual indexes need the self-healing task. It enables the CDC stream that feeds them. + props.put(QueryServices.TASK_HANDLING_INITIAL_DELAY_MS_ATTRIB, Long.toString(1)); setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); } diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/VarBinaryEncodedIndexUpsertSelectIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/VarBinaryEncodedIndexUpsertSelectIT.java index d1b5c038f52..d4cf3428e9e 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/VarBinaryEncodedIndexUpsertSelectIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/VarBinaryEncodedIndexUpsertSelectIT.java @@ -68,6 +68,8 @@ public static synchronized void doSetup() throws Exception { props.put(QueryServices.USE_STATS_FOR_PARALLELIZATION, Boolean.toString(false)); props.put(INDEX_CDC_CONSUMER_RETRY_PAUSE_MS, Integer.toString(5)); props.put(PHOENIX_INDEX_CDC_MUTATION_SERIALIZE, Boolean.FALSE.toString()); + // Eventual indexes need the self-healing task. It enables the CDC stream that feeds them. + props.put(QueryServices.TASK_HANDLING_INITIAL_DELAY_MS_ATTRIB, Long.toString(1)); setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); } diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/IndexMetadataIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/IndexMetadataIT.java index f6f946257a4..3127073ed40 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/IndexMetadataIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/IndexMetadataIT.java @@ -767,8 +767,16 @@ public void testAsyncRebuildAll() throws Exception { assertEquals(testTable, rs.getString(TABLE_NAME)); assertFalse(rs.next()); + // The SelfHealingTask scheduler is quiesced by default in mini-cluster ITs, so drive it + // manually to pick up the CREATED INDEX_REBUILD task and launch the rebuild job. + TestUtil.runSelfHealingTaskOnce(); + TestUtil.waitForIndexState(conn, indexName, PIndexState.ACTIVE); + // Once the index is ACTIVE the rebuild job has completed, drive the task again so it observes + // the finished job and transitions from STARTED to COMPLETED. + TestUtil.runSelfHealingTaskOnce(); + // Check task status String query = "SELECT * " + " FROM " + PhoenixDatabaseMetaData.SYSTEM_TASK_NAME + " WHERE " + PhoenixDatabaseMetaData.TASK_TYPE + " = " diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/PartialSystemCatalogIndexIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/PartialSystemCatalogIndexIT.java index 19c8b23655f..818f08715c5 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/PartialSystemCatalogIndexIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/PartialSystemCatalogIndexIT.java @@ -194,8 +194,6 @@ public Configuration getConfiguration(Configuration confToClone) { } }); Configuration conf = HBaseFactoryProvider.getConfigurationFactory().getConfiguration(); - conf.set(QueryServices.TASK_HANDLING_INTERVAL_MS_ATTRIB, Long.toString(Long.MAX_VALUE)); - conf.set(QueryServices.TASK_HANDLING_INITIAL_DELAY_MS_ATTRIB, Long.toString(Long.MAX_VALUE)); hbaseTestUtil = new HBaseTestingUtility(conf); setUpConfigForMiniCluster(conf); conf.set(QueryServices.EXTRA_JDBC_ARGUMENTS_ATTRIB, @@ -211,8 +209,6 @@ public Configuration getConfiguration(Configuration confToClone) { Integer.toString(0)); put(QueryServices.PHOENIX_VIEW_TTL_ENABLED, Boolean.toString(true)); put(QueryServices.PHOENIX_VIEW_TTL_TENANT_VIEWS_PER_SCAN_LIMIT, String.valueOf(1)); - put(QueryServices.TASK_HANDLING_INTERVAL_MS_ATTRIB, Long.toString(Long.MAX_VALUE)); - put(QueryServices.TASK_HANDLING_INITIAL_DELAY_MS_ATTRIB, Long.toString(Long.MAX_VALUE)); } }; diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/transform/TransformMonitorExtendedIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/transform/TransformMonitorExtendedIT.java index 2a417e446ad..0bfd3110d68 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/transform/TransformMonitorExtendedIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/transform/TransformMonitorExtendedIT.java @@ -74,6 +74,8 @@ public static synchronized void doSetup() throws Exception { serverProps.put(BaseScannerRegionObserverConstants.PHOENIX_MAX_LOOKBACK_AGE_CONF_KEY, Integer.toString(60 * 60)); // An hour serverProps.put(QueryServices.IS_NAMESPACE_MAPPING_ENABLED, Boolean.TRUE.toString()); + // The self-healing task runs the transform monitor. These tests wait for it. + serverProps.put(QueryServices.TASK_HANDLING_INITIAL_DELAY_MS_ATTRIB, Long.toString(1)); Map clientProps = Maps.newHashMapWithExpectedSize(1); clientProps.put(QueryServices.IS_NAMESPACE_MAPPING_ENABLED, Boolean.TRUE.toString()); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/monitoring/BasePhoenixMetricsIT.java b/phoenix-core/src/it/java/org/apache/phoenix/monitoring/BasePhoenixMetricsIT.java index e768d096b32..349c5ff7c99 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/monitoring/BasePhoenixMetricsIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/monitoring/BasePhoenixMetricsIT.java @@ -59,8 +59,6 @@ public abstract class BasePhoenixMetricsIT extends BaseTest { @BeforeClass public static synchronized void doSetup() throws Exception { Map props = Maps.newHashMapWithExpectedSize(3); - // Disable system task handling - props.put(QueryServices.TASK_HANDLING_INITIAL_DELAY_MS_ATTRIB, Long.toString(Long.MAX_VALUE)); // Phoenix Global client metrics are enabled by default // Enable request metric collection at the driver level props.put(QueryServices.COLLECT_REQUEST_LEVEL_METRICS, String.valueOf(true)); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/monitoring/IndexMetricsIT.java b/phoenix-core/src/it/java/org/apache/phoenix/monitoring/IndexMetricsIT.java index 0d4c7ecba51..715bec2ce40 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/monitoring/IndexMetricsIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/monitoring/IndexMetricsIT.java @@ -47,7 +47,6 @@ public class IndexMetricsIT extends ParallelStatsDisabledIT { @BeforeClass public static synchronized void doSetup() throws Exception { Map props = Maps.newHashMapWithExpectedSize(3); - props.put(QueryServices.TASK_HANDLING_INITIAL_DELAY_MS_ATTRIB, Long.toString(Long.MAX_VALUE)); // disable renewing leases as this will force spooling to happen. props.put(QueryServices.RENEW_LEASE_ENABLED, String.valueOf(false)); setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/monitoring/MetadataMetricsIT.java b/phoenix-core/src/it/java/org/apache/phoenix/monitoring/MetadataMetricsIT.java index 93a112e2cf3..e92d9e93ea0 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/monitoring/MetadataMetricsIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/monitoring/MetadataMetricsIT.java @@ -37,7 +37,6 @@ public class MetadataMetricsIT extends ParallelStatsDisabledIT { @BeforeClass public static void setup() throws Exception { Map props = Maps.newHashMapWithExpectedSize(3); - props.put(QueryServices.TASK_HANDLING_INITIAL_DELAY_MS_ATTRIB, Long.toString(Long.MAX_VALUE)); // disable renewing leases as this will force spooling to happen. props.put(QueryServices.RENEW_LEASE_ENABLED, String.valueOf(false)); setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/monitoring/connectionqueryservice/ConnectionQueryServicesMetricsIT.java b/phoenix-core/src/it/java/org/apache/phoenix/monitoring/connectionqueryservice/ConnectionQueryServicesMetricsIT.java index 57791072cda..3caea05dc46 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/monitoring/connectionqueryservice/ConnectionQueryServicesMetricsIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/monitoring/connectionqueryservice/ConnectionQueryServicesMetricsIT.java @@ -118,8 +118,6 @@ public Configuration getConfiguration(Configuration confToClone) { } }); Configuration conf = HBaseFactoryProvider.getConfigurationFactory().getConfiguration(); - conf.set(QueryServices.TASK_HANDLING_INTERVAL_MS_ATTRIB, Long.toString(Long.MAX_VALUE)); - conf.set(QueryServices.TASK_HANDLING_INITIAL_DELAY_MS_ATTRIB, Long.toString(Long.MAX_VALUE)); conf.set(PHOENIX_INDEX_CDC_CONSUMER_ENABLED, Boolean.toString(false)); hbaseTestUtil = new HBaseTestingUtility(conf); setUpConfigForMiniCluster(conf); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/query/MetaDataCachingIT.java b/phoenix-core/src/it/java/org/apache/phoenix/query/MetaDataCachingIT.java index c84d62c76a0..616a4e2afc3 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/query/MetaDataCachingIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/query/MetaDataCachingIT.java @@ -59,15 +59,12 @@ public class MetaDataCachingIT extends BaseTest { @BeforeClass public static synchronized void doSetup() throws Exception { Map props = Maps.newHashMapWithExpectedSize(1); - // We set here a tiny cache to verify that even if the total size of the cache is just enough to - // hold - // system tables and Phoenix is still functional. Please note the cache weight for system tables - // is set to - // zero to allow insertion of system tables even when the cache reaches its maximum weight. + // We set here a tiny cache to verify that even if the total size of the cache is just enough + // to hold system tables and Phoenix is still functional. Please note the cache weight for + // system tables is set to zero to allow insertion of system tables even when the cache reaches + // its maximum weight. props.put(QueryServices.MAX_CLIENT_METADATA_CACHE_SIZE_ATTRIB, "50000"); props.put(QueryServices.CLIENT_CACHE_ENCODING, "object"); - props.put(QueryServices.TASK_HANDLING_INTERVAL_MS_ATTRIB, Long.toString(Long.MAX_VALUE)); - props.put(QueryServices.TASK_HANDLING_INITIAL_DELAY_MS_ATTRIB, Long.toString(Long.MAX_VALUE)); props.put(PHOENIX_INDEX_CDC_CONSUMER_ENABLED, Boolean.toString(false)); setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); } 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 11e0b120315..03d98539856 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 @@ -604,6 +604,10 @@ public static Configuration setUpConfigForMiniCluster(Configuration conf, conf.set(IndexManagementUtil.WAL_EDIT_CODEC_CLASS_KEY, "org.apache.hadoop.hbase.regionserver.wal.IndexedWALEditCodec"); + if (conf.get(QueryServices.TASK_HANDLING_INITIAL_DELAY_MS_ATTRIB) == null) { + conf.setLong(QueryServices.TASK_HANDLING_INITIAL_DELAY_MS_ATTRIB, Long.MAX_VALUE); + } + // This results in processing one row at a time in each next operation of the aggregate region // scanner, i.e., one row pages. In other words, 0ms page allows only one row to be processed // within one page; 0ms page is equivalent to one-row page 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 2b7a37ddf09..5c9a0dec8d0 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 @@ -87,6 +87,7 @@ import org.apache.hadoop.hbase.client.TableDescriptor; import org.apache.hadoop.hbase.client.TableDescriptorBuilder; import org.apache.hadoop.hbase.client.coprocessor.Batch; +import org.apache.hadoop.hbase.coprocessor.RegionCoprocessorEnvironment; import org.apache.hadoop.hbase.filter.Filter; import org.apache.hadoop.hbase.io.ImmutableBytesWritable; import org.apache.hadoop.hbase.ipc.CoprocessorRpcUtils.BlockingRpcCallback; @@ -104,6 +105,7 @@ import org.apache.phoenix.compile.SubqueryRewriter; import org.apache.phoenix.compile.SubselectRewriter; import org.apache.phoenix.coprocessor.CompactionScanner; +import org.apache.phoenix.coprocessor.TaskRegionObserver; import org.apache.phoenix.coprocessor.generated.MetaDataProtos.ClearCacheRequest; import org.apache.phoenix.coprocessor.generated.MetaDataProtos.ClearCacheResponse; import org.apache.phoenix.coprocessor.generated.MetaDataProtos.MetaDataService; @@ -139,6 +141,7 @@ import org.apache.phoenix.parse.LikeParseNode.LikeType; import org.apache.phoenix.parse.SQLParser; import org.apache.phoenix.parse.SelectStatement; +import org.apache.phoenix.query.BaseTest; import org.apache.phoenix.query.ConnectionQueryServices; import org.apache.phoenix.query.KeyRange; import org.apache.phoenix.query.QueryConstants; @@ -1152,6 +1155,20 @@ public static void waitForIndexRebuild(Connection conn, String fullIndexName, waitForIndexState(conn, fullIndexName, indexState, 0L); } + /** + * Runs a single synchronous tick of {@link TaskRegionObserver.SelfHealingTask} against the + * SYSTEM.TASK region on the running mini-cluster. + */ + public static void runSelfHealingTaskOnce() throws Exception { + RegionCoprocessorEnvironment taskRegionEnvironment = BaseTest.getUtility() + .getRSForFirstRegionInTable(PhoenixDatabaseMetaData.SYSTEM_TASK_HBASE_TABLE_NAME) + .getRegions(PhoenixDatabaseMetaData.SYSTEM_TASK_HBASE_TABLE_NAME).get(0).getCoprocessorHost() + .findCoprocessorEnvironment(TaskRegionObserver.class.getName()); + TaskRegionObserver.SelfHealingTask task = new TaskRegionObserver.SelfHealingTask( + taskRegionEnvironment, QueryServicesOptions.DEFAULT_TASK_HANDLING_MAX_INTERVAL_MS); + task.run(); + } + private static class IndexStateCheck { public final PIndexState indexState; public final Long indexDisableTimestamp; From 2a3e9026657f905b2fb8be58cdea564d03527fd2 Mon Sep 17 00:00:00 2001 From: Andrew Purtell Date: Mon, 29 Jun 2026 11:57:06 -0700 Subject: [PATCH 2/3] Fix spotless nit --- .../main/java/org/apache/phoenix/schema/MetaDataClient.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 cdad48aa0b7..419b02e5d6f 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 @@ -4939,9 +4939,9 @@ public MutationState addColumn(PTable table, List origColumnDefs, /** * To check if TTL is defined at any of the child below we are checking it at * {@link org.apache.phoenix.coprocessor.MetaDataEndpointImpl#mutateColumn(List, ColumnMutator, int, PTable, PTable, boolean)} - * level where in function - * {@link org.apache.phoenix.coprocessor.MetaDataEndpointImpl# validateIfMutationAllowedOnParent(PTable, List, PTableType, long, byte[], byte[], byte[], List, int)} - * we are already traversing through allDescendantViews. + * level where in function {@link org.apache.phoenix.coprocessor.MetaDataEndpointImpl# + * validateIfMutationAllowedOnParent(PTable, List, PTableType, long, byte[], byte[], + * byte[], List, int)} we are already traversing through allDescendantViews. */ } From f35a1b91aa236225cb08890dfb695c8007ffdb99 Mon Sep 17 00:00:00 2001 From: Andrew Purtell Date: Mon, 23 Nov 2026 18:21:32 -0800 Subject: [PATCH 3/3] PHOENIX-7829 PhoenixTableLevelMetricsIT checks the table query time The histogram check adds GLOBAL_QUERY_TIME to the table RESULT_SET_TIME_MS and expects the sum to match the latency histogram max. GLOBAL_QUERY_TIME is a JVM-wide counter. The mini cluster runs in the same JVM, so any server-side query, such as the SYSTEM.TASK self-healing query, can add to it while the delayed test scan is open. Then the strict check fails. The histogram records the table SELECT_SQL_QUERY_TIME plus the table RESULT_SET_TIME_MS. Read the query time from the table metrics, so the check counts only the test's own query. Co-Authored-By: Claude Opus 5.5 --- .../phoenix/monitoring/PhoenixTableLevelMetricsIT.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/phoenix-core/src/it/java/org/apache/phoenix/monitoring/PhoenixTableLevelMetricsIT.java b/phoenix-core/src/it/java/org/apache/phoenix/monitoring/PhoenixTableLevelMetricsIT.java index c8424ca00b8..d9c30a639ca 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/monitoring/PhoenixTableLevelMetricsIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/monitoring/PhoenixTableLevelMetricsIT.java @@ -23,7 +23,6 @@ import static org.apache.phoenix.hbase.index.IndexRegionObserver.PHOENIX_INDEX_CDC_CONSUMER_ENABLED; import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.SYSTEM_CATALOG_NAME; import static org.apache.phoenix.monitoring.GlobalClientMetrics.GLOBAL_MUTATION_BYTES; -import static org.apache.phoenix.monitoring.GlobalClientMetrics.GLOBAL_QUERY_TIME; import static org.apache.phoenix.monitoring.GlobalClientMetrics.GLOBAL_SCAN_BYTES; import static org.apache.phoenix.monitoring.MetricType.ATOMIC_UPSERT_COMMIT_TIME; import static org.apache.phoenix.monitoring.MetricType.ATOMIC_UPSERT_SQL_COUNTER; @@ -1588,8 +1587,9 @@ private void assertHistogramMetricsForQueries(String tableName, LatencyHistogram Assert.assertEquals(ltCount, ltHistogram.getHistogram().getTotalCount()); Assert.assertEquals(szCount, sizeHistogram.getHistogram().getTotalCount()); - // Get latency metrics from table level metrics - Long queryTime = GLOBAL_QUERY_TIME.getMetric().getValue(); + // Get latency metrics from table level metrics. Do not use the global query time. It also + // counts queries from other connections in this JVM, such as server-side task queries. + long queryTime = getMetricFromTableMetrics(tableName, MetricType.SELECT_SQL_QUERY_TIME); long rsNextTime = getMetricFromTableMetrics(tableName, MetricType.RESULT_SET_TIME_MS); // Latency for queries is sum of time spent in executeQuery phase and rs.next phase. long totalLatency = queryTime + rsNextTime;