Skip to content
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-5769] Ensure partitions created by async indexer are not deleted by regular writers #12662

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

codope
Copy link
Member

@codope codope commented Jan 17, 2025

Change Logs

Ensure partitions created by async indexer are not deleted by regular writers.

  • Add a new metadata config to declare what metadata partitions to delete.
  • Fix the condition for checking whether MDT partition needs to be deleted in HoodieTable
  • Add a test in TestHoodieIndexer

Let's understand the interplay between index enable/disable boolean flag and the new config. For illustration prupose, we will assume, files and column_statsare enabled by ingestion writer, andrecord_index` is created using async indexer.

Existing boolean configs: hoodie.metadata.enable, hoodie.metadata.index.column.stats.enable and hoodie.metadata.record.index.enable.
New string config: hoodie.metadata.index.drop (this takes the index name/MDT partition name as value)

  1. Regular ingestion writer has hoodie.metadata.enable and hoodie.metadata.index.column.stats.enable set to true. And, files and column_stats index are present.
  2. Async indexer starts with setting only hoodie.metadata.enable and hoodie.metadata.record.index.enable to true. It checks the available partitions and automatically sets the columns stats config to true as well -
    props.setProperty(ENABLE_METADATA_INDEX_COLUMN_STATS.key(), "true");
  3. Indexer continues to build the record_index and that is now part of inflight metadata partitions in table config.
  4. Ingestion writer continue to log updates for files and column_stats, while indexer catches up with ingestion writer commit. Note that at this point, regular ingestion writer does not set hoodie.metadata.index.drop config, so even though the hoodie.metadata.record.index.enable is false in ingestion writer config, the record_index is not deleted.
  5. Indexer has caught up. Ingestion writer notices that in addition to files and column_stats, we have record_index fully available (not inflight) in the table config. It logs updates for all 3 indexes now.
  6. In case users want to delete record_index in future, they need to set not only hoodie.metadata.record.index.enable=false but also hoodie.metadata.index.drop=record_index.

To summarise, there is a boolean flag for enabling.disabling an index, and there is a string config to explicitly specify what index to delete. The interplay between these two decides finally, whether index needs to be disabled/dropped or not.

(boolean, string) -> enabled
true, null or non-matching -> true
false, null or no-matching -> true
true, record_index -> true
false, record_index -> false

Impact

Ensure partitions created by async indexer are not deleted by regular writers.

Risk level (write none, low medium or high below)

low

Documentation Update

Describe any necessary documentation update if there is any new feature, config, or user-facing change. If not, put "none".

  • The config description must be updated if new configs are added or the default value of the configs are changed
  • Any new feature or user-facing change requires updating the Hudi website. Please create a Jira ticket, attach the
    ticket number here and follow the instruction to make
    changes to the website.

Contributor's checklist

  • Read through contributor's guide
  • Change Logs and Impact were stated clearly
  • Adequate tests were added if applicable
  • CI passed

@github-actions github-actions bot added the size:S PR with lines of changes in (10, 100] label Jan 17, 2025
@codope codope force-pushed the HUDI-5769-indexer-del-part branch from 243dfa7 to 899cd0a Compare January 20, 2025 07:12
@codope codope force-pushed the HUDI-5769-indexer-del-part branch from 899cd0a to 0c0d9b4 Compare January 23, 2025 03:52
@github-actions github-actions bot added size:M PR with lines of changes in (100, 300] and removed size:S PR with lines of changes in (10, 100] labels Jan 23, 2025
@nsivabalan
Copy link
Contributor

thanks for the PR desc, it helps.

btw, for bullet 4 in your PR desc

4. Ingestion writer continue to log updates for files and column_stats, while indexer catches up with ingestion writer commit. Note that at this point, regular ingestion writer does not set hoodie.metadata.index.drop config, so even though the hoodie.metadata.record.index.enable is false in ingestion writer config, the record_index is not deleted.

woudn't the ingestion writer also log updates for RLI, since the table config's inflight metadata partitions will say RLI.

@nsivabalan
Copy link
Contributor

can you create a follow up ticket for doc updates. This def needs to go into some runbook in our docs.

if (dataWriteConfig.isRecordIndexEnabled()) {
HoodieData<HoodieRecord> additionalUpdates = getRecordIndexAdditionalUpserts(partitionToRecordMap.get(MetadataPartitionType.RECORD_INDEX.getPartitionPath()), commitMetadata);
partitionToRecordMap.put(RECORD_INDEX.getPartitionPath(), partitionToRecordMap.get(MetadataPartitionType.RECORD_INDEX.getPartitionPath()).union(additionalUpdates));
if (dataWriteConfig.isRecordIndexEnabled() && RECORD_INDEX.isMetadataPartitionAvailable(dataMetaClient)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

guess this was not the design.
the regular ingestion writer should log updates for partitions fully available and for partitions that are inflight.
if not, the async indexer has to do full catch up. The catch up is meant just for a race condition to ensure we do not miss any updates, but in most cases, the catch up phase should not have any work to do.
lets discuss if our understanding is different

@@ -1064,12 +1069,21 @@ private boolean shouldDeleteMetadataPartition(MetadataPartitionType partitionTyp
case RECORD_INDEX:
metadataIndexDisabled = !config.isRecordIndexEnabled();
break;
// PARTITION_STATS should have same behavior as COLUMN_STATS
case PARTITION_STATS:
metadataIndexDisabled = !config.isPartitionStatsIndexEnabled();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:) I also had to fix this in my partition stats patch.

@codope codope force-pushed the HUDI-5769-indexer-del-part branch from 0c0d9b4 to 179fc3b Compare January 24, 2025 09:48
@hudi-bot
Copy link

CI report:

Bot commands @hudi-bot supports the following commands:
  • @hudi-bot run azure re-run the last Azure build

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size:M PR with lines of changes in (100, 300]
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants