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

jojochuang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ozone.git


The following commit(s) were added to refs/heads/master by this push:
     new 8838cb79972 HDDS-16987. Intermittent failure in 
TestLeaseRecovery#testGetCommittedBlockLength*
8838cb79972 is described below

commit 8838cb79972d8a52ad693ab190d2640084a1174a
Author: Siyao Meng <[email protected]>
AuthorDate: Thu Oct 15 14:46:54 2026 -0700

    HDDS-16987. Intermittent failure in 
TestLeaseRecovery#testGetCommittedBlockLength*
    
    Co-authored-by: Claude Opus 5.5 <[email protected]>
    Co-authored-by: Wei-Chiu Chuang <[email protected]>
    Co-authored-by: Cursor <[email protected]>
---
 .../apache/hadoop/fs/ozone/TestLeaseRecovery.java   | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git 
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/TestLeaseRecovery.java
 
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/TestLeaseRecovery.java
index eda35dca66b..632470ba51d 100644
--- 
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/TestLeaseRecovery.java
+++ 
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/TestLeaseRecovery.java
@@ -39,7 +39,7 @@
 import java.io.IOException;
 import java.io.OutputStream;
 import java.net.ConnectException;
-import java.util.LinkedList;
+import java.util.List;
 import java.util.concurrent.ThreadLocalRandom;
 import java.util.concurrent.TimeoutException;
 import org.apache.commons.lang3.StringUtils;
@@ -53,6 +53,7 @@
 import org.apache.hadoop.hdds.conf.StorageUnit;
 import org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos;
 import org.apache.hadoop.hdds.scm.XceiverClientGrpc;
+import org.apache.hadoop.hdds.scm.container.ContainerID;
 import org.apache.hadoop.hdds.scm.container.ContainerInfo;
 import 
org.apache.hadoop.hdds.scm.container.common.helpers.StorageContainerException;
 import org.apache.hadoop.hdds.scm.pipeline.PipelineNotFoundException;
@@ -69,6 +70,7 @@
 import org.apache.hadoop.ozone.om.OzoneManager;
 import org.apache.hadoop.ozone.om.exceptions.OMException;
 import org.apache.hadoop.ozone.om.helpers.BucketLayout;
+import org.apache.hadoop.ozone.om.helpers.OmKeyLocationInfo;
 import org.apache.hadoop.utils.FaultInjectorImpl;
 import org.apache.ozone.test.GenericTestUtils;
 import org.apache.ozone.test.GenericTestUtils.LogCapturer;
@@ -326,7 +328,7 @@ public void testBlockPipelineClosed() throws Exception {
 
       // close the pipeline
       StorageContainerManager scm = cluster.getStorageContainerManager();
-      ContainerInfo container = closeLatestContainer();
+      ContainerInfo container = closeContainerForLastBlock(stream);
       GenericTestUtils.waitFor(() -> {
         try {
           return 
scm.getPipelineManager().getPipeline(container.getPipelineID()).isClosed();
@@ -372,7 +374,7 @@ public void testGetCommittedBlockLengthTimeout(boolean 
forceRecovery) throws Exc
         stream.flush();
 
         // close the pipeline and container
-        closeLatestContainer();
+        closeContainerForLastBlock(stream);
         // pause getCommittedBlockLength handling on all DNs to make sure all 
getCommittedBlockLength will time out
         FaultInjectorImpl injector = new FaultInjectorImpl();
         injector.setType(ContainerProtos.Type.GetCommittedBlockLength);
@@ -420,7 +422,7 @@ public void testGetCommittedBlockLengthWithException() 
throws Exception {
       stream.flush();
 
       // close the pipeline and container
-      ContainerInfo container = closeLatestContainer();
+      ContainerInfo container = closeContainerForLastBlock(stream);
       // throw exception on first DN getCommittedBlockLength handling
       FaultInjectorImpl injector = new FaultInjectorImpl();
       KeyValueHandler.setInjector(injector);
@@ -538,7 +540,7 @@ public void testRecoveryWithPartialFilledHsyncBlock() 
throws Exception {
       StorageContainerManager scm = cluster.getStorageContainerManager();
       // Close container so that new data won't be written into the same block
       // block1 is partially filled
-      ContainerInfo container = closeLatestContainer();
+      ContainerInfo container = closeContainerForLastBlock(stream);
       GenericTestUtils.waitFor(() -> {
         try {
           return 
scm.getPipelineManager().getPipeline(container.getPipelineID()).isClosed();
@@ -571,9 +573,14 @@ public void testRecoveryWithPartialFilledHsyncBlock() 
throws Exception {
     verifyData(data, (blockSize - 1) * 2, file, fs);
   }
 
-  private ContainerInfo closeLatestContainer() throws IOException, 
TimeoutException, InterruptedException {
+  /** Closes the container (and its pipeline) holding the last block written 
to {@code stream}. */
+  private ContainerInfo closeContainerForLastBlock(FSDataOutputStream stream)
+      throws IOException, TimeoutException, InterruptedException {
     StorageContainerManager scm = cluster.getStorageContainerManager();
-    ContainerInfo container = new 
LinkedList<>(scm.getContainerManager().getContainers()).getLast();
+    List<OmKeyLocationInfo> locations = ((OzoneFSOutputStream) 
stream.getWrappedStream())
+        .getWrappedOutputStream().getKeyOutputStream().getLocationInfoList();
+    ContainerInfo container = scm.getContainerManager().getContainer(
+        ContainerID.valueOf(locations.get(locations.size() - 
1).getContainerID()));
     OzoneTestUtils.closeContainer(scm, container);
     return container;
   }


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

Reply via email to