From 3c9d7794af1005180321899093956b4a7141d063 Mon Sep 17 00:00:00 2001 From: Andrew Purtell Date: Fri, 1 May 2026 16:28:10 -0700 Subject: [PATCH] PHOENIX-7826 MetadataGetTableReadLockIT wait for coprocessor swap to land --- .../end2end/MetadataGetTableReadLockIT.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) 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 392e74ddbe0..f2344fc8c93 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 @@ -23,6 +23,8 @@ import java.util.List; import java.util.Map; import java.util.concurrent.CountDownLatch; +import org.apache.hadoop.hbase.TableName; +import org.apache.hadoop.hbase.regionserver.HRegion; import org.apache.hadoop.hbase.regionserver.Region; import org.apache.hadoop.hbase.util.Bytes; import org.apache.phoenix.coprocessor.MetaDataEndpointImpl; @@ -72,6 +74,7 @@ public void testBlockedReadDoesNotBlockAnotherRead() throws Exception { BlockingMetaDataEndpointImpl.setSleepSignal(sleepSignal); BlockingMetaDataEndpointImpl.setSleepDuration(SLEEP_DURATION); TestUtil.addCoprocessor(conn, "SYSTEM.CATALOG", BlockingMetaDataEndpointImpl.class); + waitForCoprocessorOnSystemCatalog(BlockingMetaDataEndpointImpl.class); // start thread-1 and wait for signal before it starts sleeping Thread t1 = getQueryThread(tableName); @@ -94,6 +97,23 @@ public void testBlockedReadDoesNotBlockAnotherRead() throws Exception { } } + private static void waitForCoprocessorOnSystemCatalog(Class coprocessorClass) throws Exception { + final TableName sysCatalog = TableName.valueOf("SYSTEM.CATALOG"); + utility.waitFor(10000, 100, () -> { + List regions = utility.getHBaseCluster().getRegions(sysCatalog); + if (regions.isEmpty()) { + return false; + } + for (HRegion region : regions) { + if (region.getCoprocessorHost() + .findCoprocessor(coprocessorClass.getName()) == null) { + return false; + } + } + return true; + }); + } + private static Thread getQueryThread(String tableName) { Runnable runnable = () -> { try (Connection conn1 = DriverManager.getConnection(getUrl())) {