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

smengcl 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 e77a4fdb9b8 HDDS-16880. Addendum: Clear Recon candidate dir after a 
failed OM DB download (#11624)
e77a4fdb9b8 is described below

commit e77a4fdb9b8c83f732efb634a238710f8841656c
Author: Siyao Meng <[email protected]>
AuthorDate: Thu Oct 22 10:50:58 2026 -0700

    HDDS-16880. Addendum: Clear Recon candidate dir after a failed OM DB 
download (#11624)
    
    Co-authored-by: Claude Opus 5.5 <[email protected]>
---
 .../hadoop/hdds/utils/RDBSnapshotProvider.java     |  2 +-
 .../spi/impl/OzoneManagerServiceProviderImpl.java  |  8 ++---
 .../recon/spi/impl/ReconRDBSnapshotProvider.java   | 34 ----------------------
 .../impl/TestOzoneManagerServiceProviderImpl.java  | 11 +++----
 4 files changed, 8 insertions(+), 47 deletions(-)

diff --git 
a/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/RDBSnapshotProvider.java
 
b/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/RDBSnapshotProvider.java
index 238fe6c706e..8253f7bb112 100644
--- 
a/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/RDBSnapshotProvider.java
+++ 
b/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/RDBSnapshotProvider.java
@@ -193,7 +193,7 @@ public DBCheckpoint getCheckpointFromUntarredDb(Path 
untarredDbDir) throws IOExc
    * @return  path of untarred dbDir.
    * @throws IOException
    */
-  protected Path untarContentsOfTarball(File snapshot,
+  private Path untarContentsOfTarball(File snapshot,
       File untarDir, boolean deleteSnapshot) throws IOException {
     // Untar the checkpoint file.
     Path untarredDbDir = untarDir.toPath();
diff --git 
a/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/spi/impl/OzoneManagerServiceProviderImpl.java
 
b/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/spi/impl/OzoneManagerServiceProviderImpl.java
index ed9a9e49233..c896e396cfc 100644
--- 
a/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/spi/impl/OzoneManagerServiceProviderImpl.java
+++ 
b/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/spi/impl/OzoneManagerServiceProviderImpl.java
@@ -505,11 +505,9 @@ public DBCheckpoint getOzoneManagerDBSnapshot() {
       reconContext.updateHealthStatus(new AtomicBoolean(false));
       reconContext.updateErrors(
           ReconContext.ErrorCode.GET_OM_DB_SNAPSHOT_FAILED);
-      // Do not wipe the candidate dir here. The shared RDBSnapshotProvider's
-      // checkLeaderConsistency() manages it on the next attempt: kept for the
-      // same leader (so a future batched/chunked transfer can resume the parts
-      // already received), reset on a leader change. It only holds fully
-      // extracted files, see ReconRDBSnapshotProvider#untarContentsOfTarball.
+      // Clear the candidate dir, as the OM follower does after a failed 
download, so a partly extracted file
+      // is never reported to the leader as already received on the next 
attempt.
+      reconSnapshotProvider.init();
       return null;
     }
   }
diff --git 
a/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/spi/impl/ReconRDBSnapshotProvider.java
 
b/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/spi/impl/ReconRDBSnapshotProvider.java
index 2f5b7e1df61..7241178e9b9 100644
--- 
a/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/spi/impl/ReconRDBSnapshotProvider.java
+++ 
b/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/spi/impl/ReconRDBSnapshotProvider.java
@@ -37,15 +37,11 @@
 import java.net.URL;
 import java.nio.file.Files;
 import java.nio.file.Path;
-import java.nio.file.StandardCopyOption;
 import java.util.List;
 import java.util.concurrent.atomic.AtomicReference;
 import java.util.function.Supplier;
-import org.apache.commons.compress.archivers.ArchiveInputStream;
-import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
 import org.apache.commons.io.FileUtils;
 import org.apache.hadoop.hdds.server.http.HttpConfig;
-import org.apache.hadoop.hdds.utils.Archiver;
 import org.apache.hadoop.hdds.utils.HAUtils;
 import org.apache.hadoop.hdds.utils.RDBSnapshotProvider;
 import org.apache.hadoop.hdds.utils.db.DBCheckpoint;
@@ -168,36 +164,6 @@ public void downloadSnapshot(String leaderNodeID, File 
targetFile)
     });
   }
 
-  /**
-   * Extract each file to a temporary name and move it to its own name only 
once all its bytes are written.
-   * The candidate dir is kept after a failed fetch and the next request lists 
its files as already received,
-   * so an untar that fails part way (a truncated stream or a full disk) must 
not leave a partly written file there.
-   */
-  @Override
-  protected Path untarContentsOfTarball(File snapshot, File untarDir, boolean 
deleteSnapshot) throws IOException {
-    Path dir = untarDir.toPath();
-    try (ArchiveInputStream<TarArchiveEntry> in = 
Archiver.untar(Files.newInputStream(snapshot.toPath()))) {
-      for (TarArchiveEntry entry = in.getNextEntry(); entry != null; entry = 
in.getNextEntry()) {
-        Path path = dir.resolve(entry.getName());
-        if (entry.isDirectory()) {
-          Archiver.extractEntry(entry, in, entry.getSize(), dir, path);
-        } else {
-          Path tmp = path.resolveSibling(path.getFileName() + ".tmp");
-          try {
-            Archiver.extractEntry(entry, in, entry.getSize(), dir, tmp);
-            Files.move(tmp, path, StandardCopyOption.REPLACE_EXISTING);
-          } finally {
-            Files.deleteIfExists(tmp);
-          }
-        }
-      }
-    }
-    if (deleteSnapshot) {
-      FileUtils.deleteQuietly(snapshot);
-    }
-    return dir;
-  }
-
   /**
    * After the transfer completes, install the leader's hard-link inventory,
    * normalize the layout to {@code <candidate>/om.db}, then move that DB out 
of
diff --git 
a/hadoop-ozone/recon/src/test/java/org/apache/hadoop/ozone/recon/spi/impl/TestOzoneManagerServiceProviderImpl.java
 
b/hadoop-ozone/recon/src/test/java/org/apache/hadoop/ozone/recon/spi/impl/TestOzoneManagerServiceProviderImpl.java
index 70aa7c104c3..26cf563ce56 100644
--- 
a/hadoop-ozone/recon/src/test/java/org/apache/hadoop/ozone/recon/spi/impl/TestOzoneManagerServiceProviderImpl.java
+++ 
b/hadoop-ozone/recon/src/test/java/org/apache/hadoop/ozone/recon/spi/impl/TestOzoneManagerServiceProviderImpl.java
@@ -19,7 +19,6 @@
 
 import static java.nio.charset.StandardCharsets.UTF_8;
 import static java.util.Collections.emptyList;
-import static java.util.Collections.singletonList;
 import static 
org.apache.hadoop.ozone.recon.OMMetadataManagerTestUtils.getTestReconOmMetadataManager;
 import static 
org.apache.hadoop.ozone.recon.OMMetadataManagerTestUtils.initializeEmptyOmMetadataManager;
 import static 
org.apache.hadoop.ozone.recon.OMMetadataManagerTestUtils.initializeNewOmMetadataManager;
@@ -339,7 +338,7 @@ public void testGetOzoneManagerDBSnapshot(@TempDir File 
dirReconMetadata)
   }
 
   @Test
-  public void testPartiallyUntarredFileNotReportedOnRetry(@TempDir File 
dirReconMetadata) throws Exception {
+  public void testCandidateDirClearedAfterFailedDownload(@TempDir File 
dirReconMetadata) throws Exception {
     File completeSst = new File(dirReconMetadata, "000009.sst");
     File truncatedSst = new File(dirReconMetadata, "000010.sst");
     FileUtils.writeByteArrayToFile(completeSst, new byte[10_000]);
@@ -372,11 +371,9 @@ public void downloadSnapshot(String leaderNodeID, File 
targetFile) throws IOExce
     assertNull(ozoneManagerServiceProvider.getOzoneManagerDBSnapshot());
     assertNull(ozoneManagerServiceProvider.getOzoneManagerDBSnapshot());
 
-    // The fully extracted file is kept and listed as received, so the leader 
does not send it again.
-    // The truncated file must not be listed, or the leader would skip it too.
-    assertThat(requestedExclusions).containsExactly(emptyList(), 
singletonList(completeSst.getName()));
-    
assertThat(snapshotProvider.getCandidateDir().list()).containsExactly(completeSst.getName());
-    assertEquals(completeSst.length(), new 
File(snapshotProvider.getCandidateDir(), completeSst.getName()).length());
+    // The failed attempt leaves nothing behind, so the retry does not ask the 
leader to skip the truncated file.
+    assertThat(requestedExclusions).containsExactly(emptyList(), emptyList());
+    assertThat(snapshotProvider.getCandidateDir().list()).isEmpty();
   }
 
   static RocksDatabase getRocksDatabase(OMMetadataManager om) {


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

Reply via email to