[HUDI-1717] Metadata Reader should merge all the un-synced but complete instants from the dataset timeline. (#3082)
This commit is contained in:
@@ -400,7 +400,7 @@ public abstract class HoodieBackedTableMetadataWriter implements HoodieTableMeta
|
||||
// (re) init the metadata for reading.
|
||||
initTableMetadata();
|
||||
try {
|
||||
List<HoodieInstant> instantsToSync = metadata.findInstantsToSync();
|
||||
List<HoodieInstant> instantsToSync = metadata.findInstantsToSyncForWriter();
|
||||
if (instantsToSync.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
@@ -411,7 +411,7 @@ public abstract class HoodieBackedTableMetadataWriter implements HoodieTableMeta
|
||||
for (HoodieInstant instant : instantsToSync) {
|
||||
LOG.info("Syncing instant " + instant + " to metadata table");
|
||||
|
||||
Option<List<HoodieRecord>> records = HoodieTableMetadataUtil.convertInstantToMetaRecords(datasetMetaClient, instant, metadata.getSyncedInstantTime());
|
||||
Option<List<HoodieRecord>> records = HoodieTableMetadataUtil.convertInstantToMetaRecords(datasetMetaClient, instant, getLatestSyncedInstantTime());
|
||||
if (records.isPresent()) {
|
||||
commit(records.get(), MetadataPartitionType.FILES.partitionPath(), instant.getTimestamp());
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import org.apache.hudi.avro.model.HoodieCleanerPlan;
|
||||
import org.apache.hudi.avro.model.HoodieRestoreMetadata;
|
||||
import org.apache.hudi.avro.model.HoodieRollbackMetadata;
|
||||
import org.apache.hudi.common.model.HoodieCommitMetadata;
|
||||
import org.apache.hudi.common.util.Option;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@@ -40,4 +41,9 @@ public interface HoodieTableMetadataWriter extends Serializable, AutoCloseable {
|
||||
void update(HoodieRestoreMetadata restoreMetadata, String instantTime);
|
||||
|
||||
void update(HoodieRollbackMetadata rollbackMetadata, String instantTime);
|
||||
|
||||
/**
|
||||
* Return the timestamp of the latest instant synced to the metadata table.
|
||||
*/
|
||||
Option<String> getLatestSyncedInstantTime();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user