usberkeley commented on issue #11784:
URL: https://github.com/apache/hudi/issues/11784#issuecomment-2309684309
```java
protected HoodieRollbackRequest getRollbackRequestForAppend(HoodieInstant
instantToRollback, String fileNameWithPartitionToRollback) {
StoragePath fullLogFilePath = new StoragePath(basePath,
fileNameWithPartitionToRollback);
String relativePartitionPath = FSUtils.getRelativePartitionPath(new
StoragePath(basePath), fullLogFilePath.getParent());
String fileId;
String baseCommitTime;
Option<HoodieLogFile> latestLogFileOption;
Map<String, Long> logBlocksToBeDeleted = new HashMap<>();
// Old marker files may be generated from base file name before
HUDI-1517. keep compatible with them.
if (FSUtils.isBaseFile(fullLogFilePath)) {
LOG.warn("Find old marker type for log file: " +
fileNameWithPartitionToRollback);
fileId = FSUtils.getFileIdFromFilePath(fullLogFilePath);
baseCommitTime = FSUtils.getCommitTime(fullLogFilePath.getName());
StoragePath partitionPath =
FSUtils.constructAbsolutePath(config.getBasePath(), relativePartitionPath);
// NOTE: Since we're rolling back incomplete Delta Commit, it only
could have appended its
// block to the latest log-file
try {
latestLogFileOption =
FSUtils.getLatestLogFile(table.getMetaClient().getStorage(), partitionPath,
fileId,
HoodieFileFormat.HOODIE_LOG.getFileExtension(), baseCommitTime);
if (latestLogFileOption.isPresent() &&
baseCommitTime.equals(instantToRollback.getTimestamp())) {
StoragePath fullDeletePath = new StoragePath(partitionPath,
latestLogFileOption.get().getFileName());
return new HoodieRollbackRequest(relativePartitionPath,
EMPTY_STRING, EMPTY_STRING,
Collections.singletonList(fullDeletePath.toString()),
Collections.emptyMap());
}
if (latestLogFileOption.isPresent()) {
HoodieLogFile latestLogFile = latestLogFileOption.get();
// NOTE: Markers don't carry information about the cumulative size
of the blocks that have been appended,
// therefore we simply stub this value.
logBlocksToBeDeleted =
Collections.singletonMap(latestLogFile.getPathInfo().getPath().toString(),
latestLogFile.getPathInfo().getLength());
}
return new HoodieRollbackRequest(relativePartitionPath, fileId,
baseCommitTime, Collections.emptyList(), logBlocksToBeDeleted);
} catch (IOException ioException) {
throw new HoodieIOException(
"Failed to get latestLogFile for fileId: " + fileId + " in
partition: " + partitionPath,
ioException);
}
} else {
HoodieLogFile logFileToRollback = new HoodieLogFile(fullLogFilePath);
fileId = logFileToRollback.getFileId();
baseCommitTime = logFileToRollback.getBaseCommitTime();
// NOTE: We don't strictly need the exact size, but this size needs to
be positive to pass metadata payload validation.
// Therefore, we simply stub this value (1L), instead of doing a
fs call to get the exact size.
logBlocksToBeDeleted =
Collections.singletonMap(logFileToRollback.getPath().getName(), 1L);
}
// **Added by usberkeley**
// Log file can be deleted if the commit to rollback is also the commit
that created the fileGroup
if (baseCommitTime.equals(instantToRollback.getTimestamp())) {
StoragePath partitionPath =
FSUtils.constructAbsolutePath(config.getBasePath(), relativePartitionPath);
try {
latestLogFileOption =
FSUtils.getLatestLogFile(table.getMetaClient().getStorage(), partitionPath,
fileId,
HoodieFileFormat.HOODIE_LOG.getFileExtension(),
baseCommitTime);
if (latestLogFileOption.isPresent()) {
StoragePath fullFilePathToDelete = new StoragePath(partitionPath,
latestLogFileOption.get().getFileName());
return new HoodieRollbackRequest(relativePartitionPath,
EMPTY_STRING, EMPTY_STRING,
Collections.singletonList(fullFilePathToDelete.toString()),
Collections.emptyMap());
}
} catch (IOException ioException) {
throw new HoodieIOException("Failed to get latestLogFile for fileId:
" + fileId + " in partition: " + partitionPath, ioException);
}
}
return new HoodieRollbackRequest(relativePartitionPath, fileId,
baseCommitTime, Collections.emptyList(), logBlocksToBeDeleted);
}
```
--
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]