From dc82d117438f3c6732b98cd73531a9cea9a6172e Mon Sep 17 00:00:00 2001 From: Andrew Purtell Date: Sat, 21 Nov 2026 11:11:42 -0800 Subject: [PATCH] PHOENIX-8098 Fix race in ParallelPhoenixConnectionFailureTest Conn1's failure completes asynchronously on its single-thread executor, but the test checked it at once. The test could also restore the stub before conn1 ran its failing createStatement. Wait for conn1's chain to complete exceptionally before restoring the stub. After that, every later chain on conn1 fails at once. Co-Authored-By: Claude Opus 5.5 --- .../phoenix/jdbc/ParallelPhoenixConnectionFailureTest.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/phoenix-core/src/test/java/org/apache/phoenix/jdbc/ParallelPhoenixConnectionFailureTest.java b/phoenix-core/src/test/java/org/apache/phoenix/jdbc/ParallelPhoenixConnectionFailureTest.java index efd038d3191..71991569095 100644 --- a/phoenix-core/src/test/java/org/apache/phoenix/jdbc/ParallelPhoenixConnectionFailureTest.java +++ b/phoenix-core/src/test/java/org/apache/phoenix/jdbc/ParallelPhoenixConnectionFailureTest.java @@ -82,6 +82,10 @@ public void testExecuteQueryChainFailure() throws SQLException { doThrow(new SQLException()).when(connSpy1).createStatement(); parallelConn.createStatement().execute("SELECT * FROM SYSTEM.CATALOG"); hbaseTestingUtility.waitFor(WAIT_MS, () -> numStatementsCreatedOnConn2.get() == 3); + // Conn1 can fail on its own executor thread after the caller returns. + // Wait for this failure before the test restores the stub. + hbaseTestingUtility.waitFor(WAIT_MS, + () -> context.getChainOnConn1().isCompletedExceptionally()); doAnswer(answer1).when(connSpy1).createStatement(); // Should still have a successful execution only from conn2 since conn1 errored before parallelConn.createStatement().execute("SELECT * FROM SYSTEM.CATALOG");