From bac9ea825960c97ab619addda2b8c8c99f3ca207 Mon Sep 17 00:00:00 2001 From: Andrew Purtell Date: Tue, 24 Nov 2026 07:54:58 -0800 Subject: [PATCH] PHOENIX-8089 HighAvailabilityTestingUtility.createTableOnClusterPair keeps a stale connection createTableOnClusterPair connects to each cluster with empty properties. The connection query services stay in the PhoenixDriver cache for the whole test class, also across cluster restarts. The HBase client keeps its cached master stub while a master answers on that host and port. When the other cluster of the pair restarts its master on the same port, later DDL goes to the wrong cluster. HighAvailabilityGroup2IT then failed in CREATE LOCAL INDEX with TableNotFoundException. Remove the connection query services from the driver cache after each cluster's DDL, so every call opens a new HBase connection. Co-Authored-By: Claude Opus 5.5 --- .../apache/phoenix/jdbc/HighAvailabilityTestingUtility.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/phoenix-core/src/it/java/org/apache/phoenix/jdbc/HighAvailabilityTestingUtility.java b/phoenix-core/src/it/java/org/apache/phoenix/jdbc/HighAvailabilityTestingUtility.java index f87d57cbb92..ec4f823297b 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/jdbc/HighAvailabilityTestingUtility.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/jdbc/HighAvailabilityTestingUtility.java @@ -532,6 +532,10 @@ public void createTableOnClusterPair(HighAvailabilityGroup haGroup, String table */ ((PhoenixConnection) conn).getQueryServices().clearCache(); } + // Do not keep this connection's query services in the driver cache. A cached HBase + // connection can keep a stale master stub after a cluster restart. When the other cluster + // reuses that master port, later DDL goes to the wrong cluster. + PhoenixDriver.INSTANCE.invalidateCache(jdbcUrl, new Properties()); } LOG.info("Created table {} on cluster pair {}", tableName, this); }