This is an automated email from the ASF dual-hosted git repository. virajjasani pushed a commit to branch 5.2 in repository https://gitbox.apache.org/repos/asf/phoenix.git
commit 88498b1e2440e2f4844990a97e7eb3177dbb62b5 Author: Andrew Purtell <[email protected]> AuthorDate: Tue Jun 30 15:57:39 2026 -0700 PHOENIX-7952 UpsertSelectIT is flaky due to a connection leak check using a global counter (#2561) Co-authored-by: Claude Opus 4.8[1m] <[email protected]> --- .../org/apache/phoenix/end2end/UpsertSelectIT.java | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) 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 0c71efc10f..fc5cc38397 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 @@ -105,12 +105,27 @@ public class UpsertSelectIT extends ParallelStatsDisabledIT { @After public void assertNoConnLeak() throws Exception { - boolean refCountLeaked = isAnyStoreRefCountLeaked(); + // The server-side UPSERT SELECT path can open auxiliary connections that are closed + // asynchronously on background threads, so a simple synchronous read can race ahead of + // their decrement. Poll for the counter to settle down before declaring a leak. + waitForOpenConnectionsToSettle(); assertTrue(PhoenixRuntime.areGlobalClientMetricsBeingCollected()); - assertEquals(0, GLOBAL_OPEN_PHOENIX_CONNECTIONS.getMetric().getValue()); + boolean refCountLeaked = isAnyStoreRefCountLeaked(); assertFalse("refCount leaked", refCountLeaked); } + private static void waitForOpenConnectionsToSettle() throws InterruptedException { + final long timeoutMs = 30000; + final long pollIntervalMs = 100; + long deadline = EnvironmentEdgeManager.currentTimeMillis() + timeoutMs; + long openConnections = GLOBAL_OPEN_PHOENIX_CONNECTIONS.getMetric().getValue(); + while (openConnections != 0 && EnvironmentEdgeManager.currentTimeMillis() < deadline) { + Thread.sleep(pollIntervalMs); + openConnections = GLOBAL_OPEN_PHOENIX_CONNECTIONS.getMetric().getValue(); + } + assertEquals(0, openConnections); + } + // name is used by failsafe as file name in reports @Parameters(name = "UpsertSelecttIT_allowServerSideMutations={0}") public static synchronized Object[] data() {
