Skip to content

Commit 75ae016

Browse files
wxploveccAlexey Kudinkin
authored andcommitted
[HUDI-5025] Rollback failed with log file not found when rollOver in rollback process (apache#6939)
* fix rollback file not found
1 parent 265fef6 commit 75ae016

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

hudi-client/hudi-client-common/src/main/java/org/apache/hudi/table/action/rollback/BaseRollbackHelper.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ List<Pair<String, HoodieRollbackStat>> maybeDeleteAndCollectStats(HoodieEngineCo
120120
return partitionToRollbackStats.stream();
121121
} else if (!rollbackRequest.getLogBlocksToBeDeleted().isEmpty()) {
122122
HoodieLogFormat.Writer writer = null;
123+
final Path filePath;
123124
try {
124125
String fileId = rollbackRequest.getFileId();
125126
String latestBaseInstant = rollbackRequest.getLatestBaseInstant();
@@ -135,7 +136,10 @@ List<Pair<String, HoodieRollbackStat>> maybeDeleteAndCollectStats(HoodieEngineCo
135136
if (doDelete) {
136137
Map<HoodieLogBlock.HeaderMetadataType, String> header = generateHeader(instantToRollback.getTimestamp());
137138
// if update belongs to an existing log file
138-
writer.appendBlock(new HoodieCommandBlock(header));
139+
// use the log file path from AppendResult in case the file handle may roll over
140+
filePath = writer.appendBlock(new HoodieCommandBlock(header)).logFile().getPath();
141+
} else {
142+
filePath = writer.getLogFile().getPath();
139143
}
140144
} catch (IOException | InterruptedException io) {
141145
throw new HoodieRollbackException("Failed to rollback for instant " + instantToRollback, io);
@@ -153,7 +157,7 @@ List<Pair<String, HoodieRollbackStat>> maybeDeleteAndCollectStats(HoodieEngineCo
153157
// getFileStatus would reflect correct stats and FileNotFoundException is not thrown in
154158
// cloud-storage : HUDI-168
155159
Map<FileStatus, Long> filesToNumBlocksRollback = Collections.singletonMap(
156-
metaClient.getFs().getFileStatus(Objects.requireNonNull(writer).getLogFile().getPath()),
160+
metaClient.getFs().getFileStatus(Objects.requireNonNull(filePath)),
157161
1L
158162
);
159163

0 commit comments

Comments
 (0)