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

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


The following commit(s) were added to refs/heads/master by this push:
     new d047fbaed0 [HUDI-5025] Rollback failed with log file not found when 
rollOver in rollback process (#6939)
d047fbaed0 is described below

commit d047fbaed006beaa592f3a58705ce0e998d769e6
Author: 吴祥平 <[email protected]>
AuthorDate: Wed Nov 9 12:55:18 2022 +0800

    [HUDI-5025] Rollback failed with log file not found when rollOver in 
rollback process (#6939)
    
    * fix rollback file not found
---
 .../org/apache/hudi/table/action/rollback/BaseRollbackHelper.java | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git 
a/hudi-client/hudi-client-common/src/main/java/org/apache/hudi/table/action/rollback/BaseRollbackHelper.java
 
b/hudi-client/hudi-client-common/src/main/java/org/apache/hudi/table/action/rollback/BaseRollbackHelper.java
index 7cd09930c1..fa49d21391 100644
--- 
a/hudi-client/hudi-client-common/src/main/java/org/apache/hudi/table/action/rollback/BaseRollbackHelper.java
+++ 
b/hudi-client/hudi-client-common/src/main/java/org/apache/hudi/table/action/rollback/BaseRollbackHelper.java
@@ -120,6 +120,7 @@ public class BaseRollbackHelper implements Serializable {
         return partitionToRollbackStats.stream();
       } else if (!rollbackRequest.getLogBlocksToBeDeleted().isEmpty()) {
         HoodieLogFormat.Writer writer = null;
+        final Path filePath;
         try {
           String fileId = rollbackRequest.getFileId();
           String latestBaseInstant = rollbackRequest.getLatestBaseInstant();
@@ -135,7 +136,10 @@ public class BaseRollbackHelper implements Serializable {
           if (doDelete) {
             Map<HoodieLogBlock.HeaderMetadataType, String> header = 
generateHeader(instantToRollback.getTimestamp());
             // if update belongs to an existing log file
-            writer.appendBlock(new HoodieCommandBlock(header));
+            // use the log file path from AppendResult in case the file handle 
may roll over
+            filePath = writer.appendBlock(new 
HoodieCommandBlock(header)).logFile().getPath();
+          } else {
+            filePath = writer.getLogFile().getPath();
           }
         } catch (IOException | InterruptedException io) {
           throw new HoodieRollbackException("Failed to rollback for instant " 
+ instantToRollback, io);
@@ -153,7 +157,7 @@ public class BaseRollbackHelper implements Serializable {
         // getFileStatus would reflect correct stats and FileNotFoundException 
is not thrown in
         // cloud-storage : HUDI-168
         Map<FileStatus, Long> filesToNumBlocksRollback = 
Collections.singletonMap(
-            
metaClient.getFs().getFileStatus(Objects.requireNonNull(writer).getLogFile().getPath()),
+            metaClient.getFs().getFileStatus(Objects.requireNonNull(filePath)),
             1L
         );
 

Reply via email to