nsivabalan commented on code in PR #8527:
URL: https://github.com/apache/hudi/pull/8527#discussion_r1181247986
##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/metadata/HoodieBackedTableMetadataWriter.java:
##########
@@ -731,21 +733,40 @@ public void
initializeMetadataPartitions(HoodieTableMetaClient dataMetaClient, L
*/
private void initializeFileGroups(HoodieTableMetaClient dataMetaClient,
MetadataPartitionType metadataPartition, String instantTime,
int fileGroupCount) throws IOException {
- final HashMap<HeaderMetadataType, String> blockHeader = new HashMap<>();
- blockHeader.put(HeaderMetadataType.INSTANT_TIME, instantTime);
+ // Remove all existing file groups or leftover files in the partition
+ final Path partitionPath = new Path(metadataWriteConfig.getBasePath(),
metadataPartition.getPartitionPath());
+ FileSystem fs = metadataMetaClient.getFs();
+ try {
+ final FileStatus[] existingFiles = fs.listStatus(partitionPath);
+ if (existingFiles.length > 0) {
+ LOG.warn("Deleting all existing files found in MDT partition " +
metadataPartition.getPartitionPath());
+ fs.delete(partitionPath, true);
+ ValidationUtils.checkState(!fs.exists(partitionPath), "Failed to
delete MDT partition " + metadataPartition);
+ }
+ } catch (FileNotFoundException e) {
Review Comment:
if some deletion fails, we will throw all the way right and fail the
ingestion thread?
--
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]