This is an automated email from the ASF dual-hosted git repository.

tkhurana pushed a commit to branch PHOENIX-7562-feature-new
in repository https://gitbox.apache.org/repos/asf/phoenix.git


The following commit(s) were added to refs/heads/PHOENIX-7562-feature-new by 
this push:
     new 50964b5dbf PHOENIX-7885 Addendum fix flakey tests in 
ReplicationLogGroupTest
50964b5dbf is described below

commit 50964b5dbf6695360aa99a00a76b27c84d476b24
Author: tkhurana <[email protected]>
AuthorDate: Wed Jul 1 18:01:44 2026 -0700

    PHOENIX-7885 Addendum fix flakey tests in ReplicationLogGroupTest
    
    Make ReplicationLog.getWriter() a pure read to close the writer-swap race
    Deflake testClose: sync after append so the consumer starts before close
---
 .../org/apache/phoenix/replication/ReplicationLog.java    |  1 -
 .../phoenix/replication/ReplicationLogGroupTest.java      | 15 +++++++++++----
 2 files changed, 11 insertions(+), 5 deletions(-)

diff --git 
a/phoenix-core-server/src/main/java/org/apache/phoenix/replication/ReplicationLog.java
 
b/phoenix-core-server/src/main/java/org/apache/phoenix/replication/ReplicationLog.java
index dc681e8d90..4dd4eb7825 100644
--- 
a/phoenix-core-server/src/main/java/org/apache/phoenix/replication/ReplicationLog.java
+++ 
b/phoenix-core-server/src/main/java/org/apache/phoenix/replication/ReplicationLog.java
@@ -218,7 +218,6 @@ public class ReplicationLog {
 
   @VisibleForTesting
   protected LogFileWriter getWriter() {
-    checkAndReplaceWriter(false);
     return currentWriter;
   }
 
diff --git 
a/phoenix-core/src/test/java/org/apache/phoenix/replication/ReplicationLogGroupTest.java
 
b/phoenix-core/src/test/java/org/apache/phoenix/replication/ReplicationLogGroupTest.java
index fa69ac78f6..25afca0964 100644
--- 
a/phoenix-core/src/test/java/org/apache/phoenix/replication/ReplicationLogGroupTest.java
+++ 
b/phoenix-core/src/test/java/org/apache/phoenix/replication/ReplicationLogGroupTest.java
@@ -461,8 +461,13 @@ public class ReplicationLogGroupTest extends 
ReplicationLogBaseTest {
     LogFileWriter innerWriter = logGroup.getActiveLog().getWriter();
     assertNotNull("Inner writer should not be null", innerWriter);
 
-    // Append some data
+    // Append some data. The sync blocks until the consumer thread completes 
the sync future from
+    // inside onEvent, which proves it has run past 
BatchEventProcessor.run()'s opening clearAlert()
+    // and is parked in waitFor(). Without this, close() can fire before the 
consumer thread is
+    // scheduled; disruptor.shutdown()'s halt() then raises an alert that 
run()'s clearAlert()
+    // immediately wipes, so onShutdown (and thus the writer close) never runs.
     logGroup.append(tableName, commitId, put);
+    logGroup.sync();
 
     // Close the log writer
     logGroup.close();
@@ -2086,13 +2091,15 @@ public class ReplicationLogGroupTest extends 
ReplicationLogBaseTest {
     // pendingWriter — no further append/sync needed.
     waitForRotationTick(roundDurationSeconds);
 
+    // The swap runs on the consumer thread via the synthetic swap event. 
Await the initial
+    // writer's async close first: checkAndReplaceWriter assigns currentWriter 
before submitClose,
+    // so observing close() establishes happens-before on the swapped-in 
writer.
+    verify(initialWriter, timeout(5000).times(1)).close();
+
     // The active writer should now be the one staged by the rotation tick.
     LogFileWriter writerAfterIdleRotation = activeLog.getWriter();
     assertTrue("Writer should have swapped after idle rotation tick without 
further events",
       writerAfterIdleRotation != initialWriter);
-
-    // The initial writer should have been closed asynchronously by the swap.
-    verify(initialWriter, timeout(5000).times(1)).close();
   }
 
   /**

Reply via email to