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 7cd09930c1f08..fa49d21391b80 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 @@ List> maybeDeleteAndCollectStats(HoodieEngineCo 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 @@ List> maybeDeleteAndCollectStats(HoodieEngineCo if (doDelete) { Map 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 @@ List> maybeDeleteAndCollectStats(HoodieEngineCo // getFileStatus would reflect correct stats and FileNotFoundException is not thrown in // cloud-storage : HUDI-168 Map filesToNumBlocksRollback = Collections.singletonMap( - metaClient.getFs().getFileStatus(Objects.requireNonNull(writer).getLogFile().getPath()), + metaClient.getFs().getFileStatus(Objects.requireNonNull(filePath)), 1L );