-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
[HUDI-7665] Support upgrade downgrade to or from table version 8 #12327
base: master
Are you sure you want to change the base?
Conversation
@@ -153,6 +153,21 @@ public int archiveIfRequired(HoodieEngineContext context, boolean acquireLock) t | |||
txnManager.beginTransaction(Option.empty(), Option.empty()); | |||
} | |||
List<HoodieInstant> instantsToArchive = getInstantsToArchive().collect(Collectors.toList()); | |||
return archiveInstants(context, instantsToArchive, false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We will be locking twice in this code-path. Can we instead introduce a private method which archives a given list of instants and the locking/unlocking managed in the public methods.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have similiar concerns, the multiple-level falgs for lock control is error-prone, we should avoid that as much as possible, and why we need a lock for upgrade/downgrade then, I don't think there is concurrency here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. I have refactored. Not taking lock here.
...t-common/src/main/java/org/apache/hudi/client/timeline/versioning/v2/TimelineArchiverV2.java
Outdated
Show resolved
Hide resolved
...t-common/src/main/java/org/apache/hudi/client/timeline/versioning/v2/TimelineArchiverV2.java
Outdated
Show resolved
Hide resolved
...-client-common/src/main/java/org/apache/hudi/table/upgrade/EightToSevenDowngradeHandler.java
Show resolved
Hide resolved
...nt/hudi-client-common/src/main/java/org/apache/hudi/table/upgrade/UpgradeDowngradeUtils.java
Outdated
Show resolved
Hide resolved
...di-client-common/src/main/java/org/apache/hudi/table/upgrade/SevenToEightUpgradeHandler.java
Outdated
Show resolved
Hide resolved
...-client-common/src/main/java/org/apache/hudi/table/upgrade/EightToSevenDowngradeHandler.java
Show resolved
Hide resolved
...-client-common/src/main/java/org/apache/hudi/table/upgrade/EightToSevenDowngradeHandler.java
Outdated
Show resolved
Hide resolved
@@ -58,17 +66,31 @@ public class SevenToEightUpgradeHandler implements UpgradeHandler { | |||
@Override | |||
public Map<ConfigProperty, String> upgrade(HoodieWriteConfig config, HoodieEngineContext context, | |||
String instantTime, SupportsUpgradeDowngrade upgradeDowngradeHelper) { | |||
config.setValue(HoodieWriteConfig.WRITE_TABLE_VERSION, String.valueOf(HoodieTableVersion.SIX.versionCode())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why set up this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so that readers can continue reading at this time
...nt/hudi-client-common/src/main/java/org/apache/hudi/table/upgrade/UpgradeDowngradeUtils.java
Outdated
Show resolved
Hide resolved
...nt/hudi-client-common/src/main/java/org/apache/hudi/table/upgrade/UpgradeDowngradeUtils.java
Outdated
Show resolved
Hide resolved
}; | ||
try { | ||
HoodieTimelineArchiver archiver = TimelineArchivers.getInstance(TimelineLayoutVersion.LAYOUT_VERSION_2, config, table); | ||
archiver.archiveInstants(engineContext, archivedTimeline.getInstants(), true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we can read the legady archived instants in one shot. The right manner is reading them in mini-batchs then flush as the new LSM timeline.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And be caution that the legacy archived instants can be large amount, just reading the latest log should be enough for the new file slicing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
read the legacy archived instants as a iterator and flush as a accumulated mini-batch. ArchivedTimelineLoader.loadInstants
should be used instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have changed. Now, using LegacyArchivedMetaEntryReader
and LSMTimelineWriter
directly. Please check latest commit.
timelineLayoutVersion -> ValidationUtils.checkState(TimelineLayoutVersion.LAYOUT_VERSION_2.equals(timelineLayoutVersion), | ||
"Downgrade from LSM timeline is only supported for layout version 2. Given version: " + timelineLayoutVersion)); | ||
HoodieArchivedTimeline lsmArchivedTimeline = table.getMetaClient().getArchivedTimeline(); | ||
if (lsmArchivedTimeline.getInstants().isEmpty()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
read the LSM archived instants as a iterator and flush as a accumulated mini-batch. ArchivedTimelineLoader.loadInstants
should be used instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
revised, please check.
...nt/hudi-client-common/src/main/java/org/apache/hudi/table/upgrade/UpgradeDowngradeUtils.java
Outdated
Show resolved
Hide resolved
@@ -645,7 +648,9 @@ private static void createTableLayoutOnStorage(StorageConfiguration<?> storageCo | |||
} | |||
|
|||
initializeBootstrapDirsIfNotExists(basePath, storage); | |||
HoodieTableConfig.create(storage, metaPathDir, props); | |||
if (shouldCreateTableConfig) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't we always create the table properties file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, I just need to create the timeline/hstory folder without updating the configs.
...nt/hudi-client-common/src/main/java/org/apache/hudi/table/upgrade/UpgradeDowngradeUtils.java
Show resolved
Hide resolved
a0e8fb1
to
10c9bbd
Compare
8889bf7
to
c68ad35
Compare
address review comments batch instants and use LegacyArchivedMetaEntryReader and LSMTimelineWriter directly Fix archive timeline API and TestSevenToEightUpgradeHandler#testPropertyUpgrade More fixes to TimelineArchiver V2 and V1 Fix the targer archive path for timeline migration[C fix upgrade when auto upgrade is disabled fix upgrade downgrade tests fix testAutoUpgradeFailure Fix the schema mismatch and commit metadata enconding for archived timeline Fix the legacy archival reader for the instant Add a FULL read mode for lsm timeline reader archivePath as an attribute of LSMTimelineWriter and couple other fixes fix archived instant read schema More fix to the LSMTimelineWriter archive path
87fd008
to
163c1ba
Compare
Change Logs
Impact
Support upgrade downgrade to or from table version 8
Risk level (write none, low medium or high below)
high
Documentation Update
Describe any necessary documentation update if there is any new feature, config, or user-facing change. If not, put "none".
ticket number here and follow the instruction to make
changes to the website.
Contributor's checklist