[HUDI-3461] The archived timeline for flink streaming reader should not be reused (#4861)
* Before the patch, the flink streaming reader caches the meta client thus the archived timeline, when fetching the instant details from the reused timeline, the exception throws * Add a method in HoodieTableMetaClient to return a fresh new archived timeline each time
This commit is contained in:
@@ -250,22 +250,12 @@ public class IncrementalInputSplits implements Serializable {
|
||||
InstantRange instantRange,
|
||||
HoodieTimeline commitTimeline,
|
||||
String tableName) {
|
||||
if (instantRange == null || commitTimeline.isBeforeTimelineStarts(instantRange.getStartInstant())) {
|
||||
// read the archived metadata if:
|
||||
// 1. the start commit is 'earliest';
|
||||
// 2. the start instant is archived.
|
||||
HoodieArchivedTimeline archivedTimeline = metaClient.getArchivedTimeline();
|
||||
if (commitTimeline.isBeforeTimelineStarts(instantRange.getStartInstant())) {
|
||||
// read the archived metadata if the start instant is archived.
|
||||
HoodieArchivedTimeline archivedTimeline = metaClient.getArchivedTimeline(instantRange.getStartInstant());
|
||||
HoodieTimeline archivedCompleteTimeline = archivedTimeline.getCommitsTimeline().filterCompletedInstants();
|
||||
if (!archivedCompleteTimeline.empty()) {
|
||||
final String endTs = archivedCompleteTimeline.lastInstant().get().getTimestamp();
|
||||
Stream<HoodieInstant> instantStream = archivedCompleteTimeline.getInstants();
|
||||
if (instantRange != null) {
|
||||
archivedTimeline.loadInstantDetailsInMemory(instantRange.getStartInstant(), endTs);
|
||||
instantStream = instantStream.filter(s -> HoodieTimeline.compareTimestamps(s.getTimestamp(), GREATER_THAN_OR_EQUALS, instantRange.getStartInstant()));
|
||||
} else {
|
||||
final String startTs = archivedCompleteTimeline.firstInstant().get().getTimestamp();
|
||||
archivedTimeline.loadInstantDetailsInMemory(startTs, endTs);
|
||||
}
|
||||
return maySkipCompaction(instantStream)
|
||||
.map(instant -> WriteProfiles.getCommitMetadata(tableName, path, instant, archivedTimeline)).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user