-
Notifications
You must be signed in to change notification settings - Fork 2.5k
[HUDI-1740] Fix insert-overwrite API archival #2784
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
80a46cb
d3d5b40
49cfe0d
5572b9f
e2e7870
b2c037a
e491d1c
917fa7c
09ac4b4
cc724b8
ab27482
de8fbc5
d938e0a
7d05046
af963ac
2327417
a285561
39c062d
6bfc9fb
de884c6
e47c38f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -37,14 +37,18 @@ | |
| import org.apache.hudi.common.table.timeline.HoodieTimeline; | ||
| import org.apache.hudi.common.table.timeline.TimelineMetadataUtils; | ||
| import org.apache.hudi.common.util.CleanerUtils; | ||
| import org.apache.hudi.common.util.ClusteringUtils; | ||
| import org.apache.hudi.common.util.CompactionUtils; | ||
| import org.apache.hudi.common.util.Option; | ||
| import org.apache.log4j.LogManager; | ||
| import org.apache.log4j.Logger; | ||
|
|
||
| /** | ||
| * Helper class to convert between different action related payloads and {@link HoodieArchivedMetaEntry}. | ||
| */ | ||
| public class MetadataConversionUtils { | ||
|
|
||
| private static final Logger LOG = LogManager.getLogger(MetadataConversionUtils.class); | ||
|
|
||
| public static HoodieArchivedMetaEntry createMetaWrapper(HoodieInstant hoodieInstant, HoodieTableMetaClient metaClient) throws IOException { | ||
| HoodieArchivedMetaEntry archivedMetaWrapper = new HoodieArchivedMetaEntry(); | ||
| archivedMetaWrapper.setCommitTime(hoodieInstant.getTimestamp()); | ||
|
|
@@ -72,9 +76,14 @@ public static HoodieArchivedMetaEntry createMetaWrapper(HoodieInstant hoodieInst | |
| HoodieReplaceCommitMetadata replaceCommitMetadata = HoodieReplaceCommitMetadata | ||
| .fromBytes(metaClient.getActiveTimeline().getInstantDetails(hoodieInstant).get(), HoodieReplaceCommitMetadata.class); | ||
| archivedMetaWrapper.setHoodieReplaceCommitMetadata(ReplaceArchivalHelper.convertReplaceCommitMetadata(replaceCommitMetadata)); | ||
| } else if (hoodieInstant.isInflight()) { | ||
| // inflight replacecommit files have the same meta data body as HoodieCommitMetadata | ||
|
ssdong marked this conversation as resolved.
|
||
| // so we could re-use it without further creating an inflight extension | ||
| HoodieCommitMetadata inflightCommitMetadata = HoodieCommitMetadata | ||
| .fromBytes(metaClient.getActiveTimeline().getInstantDetails(hoodieInstant).get(), HoodieCommitMetadata.class); | ||
| archivedMetaWrapper.setHoodieInflightReplaceMetadata(convertCommitMetadata(inflightCommitMetadata)); | ||
| } else { | ||
| HoodieRequestedReplaceMetadata requestedReplaceMetadata = | ||
| ClusteringUtils.getRequestedReplaceMetadata(metaClient, hoodieInstant).get(); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using |
||
| HoodieRequestedReplaceMetadata requestedReplaceMetadata = getRequestedReplaceMetadata(metaClient, hoodieInstant).get(); | ||
| archivedMetaWrapper.setHoodieRequestedReplaceMetadata(requestedReplaceMetadata); | ||
| } | ||
| archivedMetaWrapper.setActionType(ActionType.replacecommit.name()); | ||
|
|
@@ -105,14 +114,15 @@ public static HoodieArchivedMetaEntry createMetaWrapper(HoodieInstant hoodieInst | |
| return archivedMetaWrapper; | ||
| } | ||
|
|
||
| public static HoodieArchivedMetaEntry createMetaWrapper(HoodieInstant hoodieInstant, | ||
| HoodieCommitMetadata hoodieCommitMetadata) { | ||
| HoodieArchivedMetaEntry archivedMetaWrapper = new HoodieArchivedMetaEntry(); | ||
| archivedMetaWrapper.setCommitTime(hoodieInstant.getTimestamp()); | ||
| archivedMetaWrapper.setActionState(hoodieInstant.getState().name()); | ||
| archivedMetaWrapper.setHoodieCommitMetadata(convertCommitMetadata(hoodieCommitMetadata)); | ||
| archivedMetaWrapper.setActionType(ActionType.commit.name()); | ||
| return archivedMetaWrapper; | ||
| public static Option<HoodieRequestedReplaceMetadata> getRequestedReplaceMetadata(HoodieTableMetaClient metaClient, HoodieInstant pendingReplaceInstant) throws IOException { | ||
| final HoodieInstant requestedInstant = HoodieTimeline.getReplaceCommitRequestedInstant(pendingReplaceInstant.getTimestamp()); | ||
|
|
||
| Option<byte[]> content = metaClient.getActiveTimeline().getInstantDetails(requestedInstant); | ||
| if (!content.isPresent() || content.get().length == 0) { | ||
| LOG.warn("No content found in requested file for instant " + pendingReplaceInstant); | ||
| return Option.of(new HoodieRequestedReplaceMetadata()); | ||
|
ssdong marked this conversation as resolved.
Outdated
|
||
| } | ||
| return Option.of(TimelineMetadataUtils.deserializeRequestedReplaceMetadata(content.get())); | ||
| } | ||
|
|
||
| public static org.apache.hudi.avro.model.HoodieCommitMetadata convertCommitMetadata( | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -245,7 +245,7 @@ public final void reset() { | |
| bootstrapIndex = null; | ||
|
|
||
| // Initialize with new Hoodie timeline. | ||
| init(metaClient, getTimeline()); | ||
| init(metaClient, metaClient.reloadActiveTimeline()); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IIUC, this is breaking some fundamental assumptions. There are many places where we pass "trimmed" timeline for time-travel queries etc. You are replacing that with all instants from active timeline, which is not desired. Is this change needed if we handle empty partitionToReplaceFileIds in archival?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @satishkotha
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the root problem is why we are calling reset() when close the timeline
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @bvaradar mentioned this is by design. Balaji, could you please help resolve this?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've put |
||
| } finally { | ||
| writeLock.unlock(); | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.