hgromer commented on code in PR #7151:
URL: https://github.com/apache/hbase/pull/7151#discussion_r2198628599


##########
hbase-backup/src/main/java/org/apache/hadoop/hbase/backup/impl/IncrementalTableBackupClient.java:
##########
@@ -370,13 +376,56 @@ protected void deleteBulkLoadDirectory() throws 
IOException {
     }
   }
 
-  protected void convertWALsToHFiles() throws IOException {
-    // get incremental backup file list and prepare parameters for DistCp
-    List<String> incrBackupFileList = backupInfo.getIncrBackupFileList();
+  protected Set<String> convertWALsToHFiles() throws IOException {
+    Set<String> backupFiles = new 
HashSet<>(backupInfo.getIncrBackupFileList());
+    // filter missing files out (they have been copied by previous backups)
+    backupFiles = filterMissingFiles(backupFiles);
+    int attempt = 1;
+    int maxAttempts =
+      conf.getInt(CONVERT_TO_WAL_TO_HFILES_ATTEMPTS_KEY, 
CONVERT_TO_WAL_TO_HFILES_ATTEMPTS_DEFAULT);
+
+    while (attempt <= maxAttempts) {
+      try {
+        LOG.info("Converting WALs to HFiles. Attempt={}/{}", attempt, 
maxAttempts);
+        convertWALsToHFiles(backupFiles);
+        return backupFiles;
+      } catch (FileNotFoundException e) {
+        LOG.warn("Failed to convert WALs to HFiles", e);
+        // We need to deal with the possibility of the active WAL file being 
rolled over
+        // as we're trying to copy it
+
+        Set<String> newBackupFiles = new HashSet<>(backupFiles.size());
+        for (String file : backupFiles) {
+          Path path = new Path(file);
+          if (!isActiveWalPath(path) || fs.exists(path)) {
+            newBackupFiles.add(file);
+            continue;
+          }
+
+          Path archive = AbstractFSWALProvider.findArchivedLog(path, conf);
+          if (archive == null) {
+            throw new IOException("Could not find archive for missing WAL file 
" + path);
+          }
+
+          LOG.info("WAL file {} was archived during backup process, using 
archive {}", path,
+            archive);
+          newBackupFiles.add(archive.toString());
+        }
+
+        if (newBackupFiles.equals(backupFiles)) {
+          throw e;
+        }
+
+        backupFiles = newBackupFiles;
+        ++attempt;
+      }
+    }
+    throw new IOException("Failed to convert WALs to HFiles after " + attempt 
+ " attempts");
+  }
+
+  private void convertWALsToHFiles(Set<String> incrBackupFileList) throws 
IOException {
     // Get list of tables in incremental backup set
     Set<TableName> tableSet = backupManager.getIncrementalBackupTableSet();
-    // filter missing files out (they have been copied by previous backups)

Review Comment:
   Moved 
[here](https://github.com/apache/hbase/pull/7151/files#diff-d44279b349b29247eebe7dc5f5e326491094b7e199f8e8967ec20dbd59d33c1bR382)
 to avoid filtering multiple times



-- 
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]

Reply via email to