[HUDI-2286] Handle the case of failed deltacommit on the metadata table. (#3428)
A failed deltacommit on the metadata table will be automatically rolled back. Assuming the failed commit was "t10", the rollback will happen the next time at "t11". Post rollback, when we try to sync the dataset to the metadata table, we should look for all unsynched instants including t11. Current code ignores t11 since the latest commit timestamp on metadata table is t11 (due to rollback).
This commit is contained in:
@@ -274,6 +274,30 @@ public class FileCreateUtils {
|
||||
return markerFilePath.toAbsolutePath().toString();
|
||||
}
|
||||
|
||||
private static void removeMetaFile(String basePath, String instantTime, String suffix) throws IOException {
|
||||
Path parentPath = Paths.get(basePath, HoodieTableMetaClient.METAFOLDER_NAME);
|
||||
Path metaFilePath = parentPath.resolve(instantTime + suffix);
|
||||
if (Files.exists(metaFilePath)) {
|
||||
Files.delete(metaFilePath);
|
||||
}
|
||||
}
|
||||
|
||||
public static void deleteCommit(String basePath, String instantTime) throws IOException {
|
||||
removeMetaFile(basePath, instantTime, HoodieTimeline.COMMIT_EXTENSION);
|
||||
}
|
||||
|
||||
public static void deleteRequestedCommit(String basePath, String instantTime) throws IOException {
|
||||
removeMetaFile(basePath, instantTime, HoodieTimeline.REQUESTED_COMMIT_EXTENSION);
|
||||
}
|
||||
|
||||
public static void deleteInflightCommit(String basePath, String instantTime) throws IOException {
|
||||
removeMetaFile(basePath, instantTime, HoodieTimeline.INFLIGHT_COMMIT_EXTENSION);
|
||||
}
|
||||
|
||||
public static void deleteDeltaCommit(String basePath, String instantTime) throws IOException {
|
||||
removeMetaFile(basePath, instantTime, HoodieTimeline.DELTA_COMMIT_EXTENSION);
|
||||
}
|
||||
|
||||
public static long getTotalMarkerFileCount(String basePath, String partitionPath, String instantTime, IOType ioType) throws IOException {
|
||||
Path parentPath = Paths.get(basePath, HoodieTableMetaClient.TEMPFOLDER_NAME, instantTime, partitionPath);
|
||||
if (Files.notExists(parentPath)) {
|
||||
|
||||
Reference in New Issue
Block a user