[HUDI-2923] Fixing metadata table reader when metadata compaction is inflight (#4206)
* [HUDI-2923] Fixing metadata table reader when metadata compaction is inflight * Fixing retry of pending compaction in metadata table and enhancing tests
This commit is contained in:
committed by
GitHub
parent
94f45e928c
commit
1d4fb827e7
@@ -519,6 +519,13 @@ public abstract class AbstractHoodieWriteClient<T extends HoodieRecordPayload, I
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Run any pending compactions.
|
||||
*/
|
||||
public void runAnyPendingCompactions() {
|
||||
runAnyPendingCompactions(createTable(config, hadoopConf, config.isMetadataTableEnabled()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a savepoint based on the latest commit action on the timeline.
|
||||
*
|
||||
|
||||
@@ -682,7 +682,10 @@ public abstract class HoodieBackedTableMetadataWriter implements HoodieTableMeta
|
||||
* deltacommit.
|
||||
*/
|
||||
protected void compactIfNecessary(AbstractHoodieWriteClient writeClient, String instantTime) {
|
||||
String latestDeltacommitTime = metadataMetaClient.getActiveTimeline().getDeltaCommitTimeline().filterCompletedInstants().lastInstant()
|
||||
// finish off any pending compactions if any from previous attempt.
|
||||
writeClient.runAnyPendingCompactions();
|
||||
|
||||
String latestDeltacommitTime = metadataMetaClient.reloadActiveTimeline().getDeltaCommitTimeline().filterCompletedInstants().lastInstant()
|
||||
.get().getTimestamp();
|
||||
List<HoodieInstant> pendingInstants = dataMetaClient.reloadActiveTimeline().filterInflightsAndRequested()
|
||||
.findInstantsBefore(latestDeltacommitTime).getInstants().collect(Collectors.toList());
|
||||
@@ -693,6 +696,7 @@ public abstract class HoodieBackedTableMetadataWriter implements HoodieTableMeta
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Trigger compaction with suffixes based on the same instant time. This ensures that any future
|
||||
// delta commits synced over will not have an instant time lesser than the last completed instant on the
|
||||
// metadata table.
|
||||
|
||||
Reference in New Issue
Block a user