yandrey321 opened a new pull request, #11227:
URL: https://github.com/apache/ozone/pull/11227

   ## What changes were proposed in this pull request?
   
   TestCommitWatcher#testReleaseBuffersOnException (and testReleaseBuffers, 
which shares the same setup) intermittently fail because the test starts 
writing to a freshly-allocated RATIS THREE pipeline before that pipeline's 
Ratis group has elected a leader.
   
   @BeforeEach calls cluster.waitForClusterToBeReady(), which waits only for 
datanode registration and SCM readiness — not for the pipeline's leader 
election. When the first putBlock/watch lands before a leader is settled, Ratis 
returns NotLeaderException; under the test's deliberately short (3s) 
request/watch timeouts the retries are exhausted and the client is closed, 
surfacing as:
   
   
   NotLeaderException
     -> RaftRetryFailureException
     -> AlreadyClosedException: SlidingWindow$Client:client-...->RAFT is closed.
   The failure occurs at future1.get() during setup, before the test reaches 
the datanode-shutdown scenario it actually exercises.
   
   The fix adds one call in @BeforeEach, after the cluster is ready, to wait 
for the RATIS THREE pipeline to reach OPEN before any writes:
   
   
   cluster.waitForClusterToBeReady();
   // Wait for the RATIS THREE pipeline to reach OPEN state before any writes.
   // A pipeline only opens once it is healthy, which requires an elected Ratis
   // leader; otherwise the first write can race leader election and fail with
   // NotLeaderException -> RaftRetryFailureException -> AlreadyClosedException.
   cluster.waitForPipelineTobeReady(HddsProtos.ReplicationFactor.THREE, 60000);
   This closes the race deterministically: SCM transitions a RATIS pipeline to 
OPEN only when Pipeline.isHealthy() is true, and for a RATIS pipeline 
isHealthy() requires all datanodes to have reported and leaderId != null. So 
once the pipeline is OPEN, a leader has been elected and reported — exactly the 
precondition the writes depend on. The change reuses the existing 
MiniOzoneCluster.waitForPipelineTobeReady(...) helper (no new abstraction) and, 
being in @BeforeEach, protects both tests in the class.
   
   This is a test-only change; no production code is affected.
   
   Generated-by: Claude Code (Claude Opus 4.8)
   
   
   ## What is the link to the Apache JIRA
   
   https://issues.apache.org/jira/browse/HDDS-16398
   
   ## How was this patch tested?
   
   CI: 
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to