From 1d36e458d7260be255a9577b25079e25dafe4522 Mon Sep 17 00:00:00 2001 From: Andrew Purtell Date: Sun, 22 Nov 2026 10:32:08 -0800 Subject: [PATCH] PHOENIX-8101 PhoenixMetricsIT asserts nonzero millisecond timings for short operations HBase computes MILLIS_BETWEEN_NEXTS as a sum of wall-clock millisecond deltas between scanner creation and each scan RPC response. The global metric tests scan 10 rows in one region, which takes one RPC. When that RPC finishes within the same millisecond tick the sum is 0, so the "> 0" checks fail intermittently on fast hosts. MUTATION_COMMIT_TIME is also a wall-clock millisecond delta, and a commit of 10 small rows can also finish within one tick. Assert instead that the operation records each metric (sample count > 0), and keep the strict checks on the other scan and mutation metrics. Co-Authored-By: Claude Opus 5.5 --- .../phoenix/monitoring/PhoenixMetricsIT.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/phoenix-core/src/it/java/org/apache/phoenix/monitoring/PhoenixMetricsIT.java b/phoenix-core/src/it/java/org/apache/phoenix/monitoring/PhoenixMetricsIT.java index 4a457174f01..17dd333e646 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/monitoring/PhoenixMetricsIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/monitoring/PhoenixMetricsIT.java @@ -213,7 +213,9 @@ public void testGlobalPhoenixMetricsForQueries() throws Exception { assertTrue(GLOBAL_TASK_EXECUTION_TIME.getMetric().getValue() > 0); assertTrue(GLOBAL_HBASE_COUNT_RPC_CALLS.getMetric().getValue() > 0); - assertTrue(GLOBAL_HBASE_COUNT_MILLS_BETWEEN_NEXTS.getMetric().getValue() > 0); + // HBase adds whole milliseconds between scan calls. A short scan can finish in less + // than one millisecond, so the value can be zero. Check only that the scan records it. + assertTrue(GLOBAL_HBASE_COUNT_MILLS_BETWEEN_NEXTS.getMetric().getNumberOfSamples() > 0); assertTrue(GLOBAL_HBASE_COUNT_BYTES_REGION_SERVER_RESULTS.getMetric().getValue() > 0); assertTrue(GLOBAL_HBASE_COUNT_SCANNED_REGIONS.getMetric().getValue() > 0); @@ -229,7 +231,9 @@ public void testGlobalPhoenixMetricsForMutations() throws Exception { assertEquals(10, GLOBAL_MUTATION_BATCH_SIZE.getMetric().getValue()); assertEquals(10, GLOBAL_MUTATION_SQL_COUNTER.getMetric().getValue()); assertTrue(GLOBAL_MUTATION_BYTES.getMetric().getValue() > 0); - assertTrue(GLOBAL_MUTATION_COMMIT_TIME.getMetric().getValue() > 0); + // The commit time has whole-millisecond resolution. A small commit can finish in less + // than one millisecond, so the value can be zero. Check only that the commit records it. + assertTrue(GLOBAL_MUTATION_COMMIT_TIME.getMetric().getNumberOfSamples() > 0); assertEquals(0, GLOBAL_NUM_PARALLEL_SCANS.getMetric().getValue()); assertEquals(0, GLOBAL_SELECT_SQL_COUNTER.getMetric().getValue()); assertEquals(0, GLOBAL_REJECTED_TASK_COUNTER.getMetric().getValue()); @@ -264,7 +268,9 @@ public void testGlobalPhoenixMetricsForUpsertSelect() throws Exception { assertEquals(0, GLOBAL_QUERY_TIME.getMetric().getValue()); assertTrue(GLOBAL_SCAN_BYTES.getMetric().getValue() > 0); assertTrue(GLOBAL_MUTATION_BYTES.getMetric().getValue() > 0); - assertTrue(GLOBAL_MUTATION_COMMIT_TIME.getMetric().getValue() > 0); + // The commit time has whole-millisecond resolution. A small commit can finish in less + // than one millisecond, so the value can be zero. Check only that the commit records it. + assertTrue(GLOBAL_MUTATION_COMMIT_TIME.getMetric().getNumberOfSamples() > 0); assertEquals(0, GLOBAL_SELECT_SQL_COUNTER.getMetric().getValue()); assertEquals(0, GLOBAL_REJECTED_TASK_COUNTER.getMetric().getValue()); assertEquals(0, GLOBAL_QUERY_TIMEOUT_COUNTER.getMetric().getValue()); @@ -274,7 +280,9 @@ public void testGlobalPhoenixMetricsForUpsertSelect() throws Exception { assertEquals(0, GLOBAL_MUTATION_INDEX_COMMIT_FAILURE_COUNT.getMetric().getValue()); assertTrue(GLOBAL_HBASE_COUNT_RPC_CALLS.getMetric().getValue() > 0); - assertTrue(GLOBAL_HBASE_COUNT_MILLS_BETWEEN_NEXTS.getMetric().getValue() > 0); + // HBase adds whole milliseconds between scan calls. A short scan can finish in less + // than one millisecond, so the value can be zero. Check only that the scan records it. + assertTrue(GLOBAL_HBASE_COUNT_MILLS_BETWEEN_NEXTS.getMetric().getNumberOfSamples() > 0); assertTrue(GLOBAL_HBASE_COUNT_BYTES_REGION_SERVER_RESULTS.getMetric().getValue() > 0); assertTrue(GLOBAL_HBASE_COUNT_SCANNED_REGIONS.getMetric().getValue() > 0);