-
Notifications
You must be signed in to change notification settings - Fork 2.5k
[HUDI-4138] Fix the concurrency modification of hoodie table config f… #5660
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 all commits
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 |
|---|---|---|
|
|
@@ -105,13 +105,9 @@ protected HoodieIndex getIndex(HoodieWriteConfig config, HoodieEngineContext con | |
| public <T extends SpecificRecordBase> Option<HoodieTableMetadataWriter> getMetadataWriter(String triggeringInstantTimestamp, | ||
| Option<T> actionMetadata) { | ||
| if (config.isMetadataTableEnabled()) { | ||
| // even with metadata enabled, some index could have been disabled | ||
| // delete metadata partitions corresponding to such indexes | ||
| deleteMetadataIndexIfNecessary(); | ||
| return Option.of(FlinkHoodieBackedTableMetadataWriter.create(context.getHadoopConf().get(), config, | ||
| context, actionMetadata, Option.of(triggeringInstantTimestamp))); | ||
| } else { | ||
| maybeDeleteMetadataTable(); | ||
|
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. @codope and here |
||
| return Option.empty(); | ||
| } | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -272,8 +272,8 @@ private static Properties getOrderedPropertiesWithTableChecksum(Properties props | |
| * @throws IOException | ||
| */ | ||
| private static String storeProperties(Properties props, FSDataOutputStream outputStream) throws IOException { | ||
| String checksum; | ||
| if (props.containsKey(TABLE_CHECKSUM.key()) && validateChecksum(props)) { | ||
| final String checksum; | ||
| if (isValidChecksum(props)) { | ||
| checksum = props.getProperty(TABLE_CHECKSUM.key()); | ||
| props.store(outputStream, "Updated at " + Instant.now()); | ||
| } else { | ||
|
|
@@ -285,8 +285,8 @@ private static String storeProperties(Properties props, FSDataOutputStream outpu | |
| return checksum; | ||
| } | ||
|
|
||
| private boolean isValidChecksum() { | ||
| return contains(TABLE_CHECKSUM) && validateChecksum(props); | ||
| private static boolean isValidChecksum(Properties props) { | ||
|
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. 👍 |
||
| return props.containsKey(TABLE_CHECKSUM.key()) && validateChecksum(props); | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -298,20 +298,13 @@ public HoodieTableConfig() { | |
|
|
||
| private void fetchConfigs(FileSystem fs, String metaPath) throws IOException { | ||
| Path cfgPath = new Path(metaPath, HOODIE_PROPERTIES_FILE); | ||
| Path backupCfgPath = new Path(metaPath, HOODIE_PROPERTIES_FILE_BACKUP); | ||
| try (FSDataInputStream is = fs.open(cfgPath)) { | ||
| props.load(is); | ||
| // validate checksum for latest table version | ||
| if (getTableVersion().versionCode() >= HoodieTableVersion.FOUR.versionCode() && !isValidChecksum()) { | ||
| LOG.warn("Checksum validation failed. Falling back to backed up configs."); | ||
| try (FSDataInputStream fsDataInputStream = fs.open(backupCfgPath)) { | ||
| props.load(fsDataInputStream); | ||
| } | ||
| } | ||
|
Comment on lines
-304
to
-310
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. this checksum validation is reverted?
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. @codope i suppose this check is optional and removing meant for reducing chance of the access?
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. When the code invokes, the backup file was very probably not exist, and we already load the backfile if any error happens.
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. @danny0405 but why we'd want to omit the validation?
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. The current code is problematic, based on the fact the config file and backup config file can only exists one at a time point. We already check the checksum in the modification code path. There is no need to check again in the read path. And falling back to backup file is not a reasonable way, more proper to throws exception here, but i would let @codope do that in following PR. |
||
| } catch (IOException ioe) { | ||
| if (!fs.exists(cfgPath)) { | ||
| LOG.warn("Run `table recover-configs` if config update/delete failed midway. Falling back to backed up configs."); | ||
| // try the backup. this way no query ever fails if update fails midway. | ||
| Path backupCfgPath = new Path(metaPath, HOODIE_PROPERTIES_FILE_BACKUP); | ||
| try (FSDataInputStream is = fs.open(backupCfgPath)) { | ||
| props.load(is); | ||
| } | ||
|
|
@@ -631,7 +624,7 @@ public List<String> getMetadataPartitions() { | |
| CONFIG_VALUES_DELIMITER | ||
| ); | ||
| } | ||
|
|
||
| /** | ||
| * Returns the format to use for partition meta files. | ||
| */ | ||
|
|
||
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.
@codope can you please elaborate on the original intent here?