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); }