Area: Ingestion
Sub-Area: Stateful Ingestion
Applies to: OSS + Cloud
Issue
Stateful ingestion is on for a recipe. After a run, assets are missing from DataHub. Or assets that are gone from the source, or that got a new name, still show in DataHub next to the new ones.
A run can also report this failure:
Skipping stateful ingestion / stale entity removal
Entity difference exceeds fail_safe_threshold; skipping stale entity removal.
You Might Be Asking
- What is stateful ingestion and when should I use it?
- How do I reset the stateful ingestion state?
- Why are my assets disappearing after enabling stateful ingestion?
- What should I set
fail_safe_thresholdto?
Cause
Stateful ingestion stores the list of URNs that each run ingests. DataHub stores this state against the recipe's top-level pipeline_name.
remove_stale_metadata is on by default. With it, each run soft deletes the URNs that were in the last successful run but are missing from this run.
Assets go missing or stay for these reasons:
- The recipe's patterns got narrower. Assets outside the new patterns look stale, so the run soft deletes them.
- Two recipes for the same connector use the same
pipeline_name. Each run compares its URNs with the URNs of the other recipe. If the scopes overlap enough to stay under the fail-safe (see the next item), the run soft deletes the difference. If not, each run trips the fail-safe and reports the failure above. - More than
fail_safe_thresholdpercent of the last run's URNs are missing from this run. The default is 75. The run then soft deletes nothing and reports the failure above. A change that gives many assets new URNs, such as a newplatform_instanceorenv, does this. The old URNs stay in DataHub. - The
pipeline_namechanged. The new name starts with no state, so URNs from runs under the old name are never removed.
Solution
Give each recipe its own pipeline_name
- Set a top-level
pipeline_namethat is unique to the recipe, and do not change it between runs. - Do not use one
pipeline_namefor two recipes. The recipes read and overwrite each other's state. - Ingestion sources that you create in the DataHub UI get a
pipeline_nameautomatically.
Keep the fail-safe on
- Keep
fail_safe_thresholdat its default of 75, or set a lower value to make it stricter. - Do not set
fail_safe_thresholdto 100. A value of 100 turns the fail-safe off, so one run can soft delete any number of assets. - If a change that you planned trips the fail-safe, set
fail_safe_thresholdto 100 for one run only, then remove it. That run soft deletes all the old URNs.
pipeline_name: snowflake-prod # unique to this recipe; do not change it
source:
type: snowflake
config:
# connection settings ...
stateful_ingestion:
enabled: true
# remove_stale_metadata is true by default.
# fail_safe_threshold is 75 by default. Do not set it to 100.
Reset the state
To make the next run ignore the stored state, add ignore_old_state:
source:
config:
stateful_ingestion:
enabled: true
ignore_old_state: true
- Run the recipe once, then remove
ignore_old_state. That run soft deletes nothing and stores a new state for the next run. - Keep
enabled: truein thestateful_ingestionblock. A block without it turns stateful ingestion off. - You can also set a new top-level
pipeline_name. The new name starts with no state. Stateful ingestion then never removes the URNs from runs under the old name, so soft delete those yourself. - Setting
remove_stale_metadata: truedoes not reset the state. It is already the default. - DataHub stores the state against the
pipeline_name. To reset it, useignore_old_stateor a newpipeline_name. There is no local state directory to delete, and no GraphQL API, UI action or CLI command clears the state.datahub state inspect --pipeline-name <name> --platform <platform>only shows the stored state.
The settings are in Stateful Ingestion. The pipeline_name rules are in Pipeline name.
Related Documentation
Tags: stateful-ingestion, ingestion, checkpoint, state, duplicates, missing-assets, stale-metadata, remove-stale