Area: Ingestion
Sub-Area: Stateful Ingestion
Applies to: OSS + Cloud
Issue
Stateful ingestion fails to start, or a run does not remove stale entities as you expect. You may see a pipeline_name must be set error, or a run that reports 'Skipping stateful ingestion / stale entity removal'.
You Might Be Asking
- Why does my stateful ingestion recipe fail with
pipeline_name must be set when stateful ingestion is enabled? - Why was stale entity removal skipped on my run?
- How do I make a run ignore the previous checkpoint?
Cause
Stateful ingestion in DataHub is used for stale entity removal. With remove_stale_metadata set to true (the default), DataHub soft-deletes the entities that were in the last successful run but are missing from the current run.
Common causes of problems:
-
No
pipeline_name. CLI runs need a top-levelpipeline_namethat is unique to the source configuration and stable across runs. Without it, the run fails with aConfigurationError:pipeline_name must be set when stateful ingestion is enabled.... UI-managed sources get apipeline_nameautomatically (the ingestion source URN), and an explicitpipeline_namein the recipe is kept. -
A changed
pipeline_name. The next run has no previous state. -
stateful_ingestionset in the wrong place. The block goes undersource.config. -
No connection to DataHub. The default
datahubstate provider needs a DataHub connection. It gets one from adatahub_apiset in the state provider's own config, or from the pipeline-level connection, which exists when you use adatahub-restsink or set a pipeline-leveldatahub_api. With none of these, the run fails with 'A graph instance is required. Either pass one in the pipeline context, or set it explicitly in the stateful ingestion provider config.' -
Stale entity removal skipped. The run reports a failure or warning titled 'Skipping stateful ingestion / stale entity removal' in these cases:
- The change exceeds
fail_safe_threshold.fail_safe_threshold(default 75.0, range 0 to 100) is the percentage of the previous run's entities that are missing from the current run. It does not compare total counts, so a run with the same or a higher entity count can trip it when URNs change, for example after you changeplatform_instance,envor casing. The message reads 'Entity difference exceeds fail_safe_threshold; skipping stale entity removal. To update, set stateful_ingestion.fail_safe_threshold in your recipe.' The context showsprevious_run=X entities, current_run=Y entities, change=Z%, threshold=75.0. The run soft-deletes nothing and carries the previous run's URNs into the new state, so the stale entities are removed on the next successful run. - The source already reported a failure. The run records a warning: 'The soft-deletion of stale entities will be skipped because the source reported a failure.'
- The source produced no events. The run records a failure: 'The source did not produce any metadata. Despite stateful ingestion being enabled, we will not delete any metadata. This is a fail-safe mechanism to prevent the accidental deletion of all entities.'
- The change exceeds
Solution
-
Add a
pipeline_nameand thestateful_ingestionblock. Use a name that is unique to this source and does not change between runs:
pipeline_name: my_snowflake_prod
source:
type: snowflake
config:
stateful_ingestion:
enabled: true
remove_stale_metadata: true
fail_safe_threshold: 75.0
The stateful_ingestion block must set enabled: true. Setting other keys in the block without enabled leaves it disabled. Make sure the run has a DataHub connection, for example a datahub-rest sink or a pipeline-level datahub_api. See Stateful ingestion and Pipeline name.
-
Read the run report. Look for the 'Skipping stateful ingestion / stale entity removal' title and the message under it. Fix the cause it shows:
- Source failure or zero events: fix the source error first, then run again.
-
fail_safe_thresholdexceeded: check whether URNs changed (platform_instance,env, casing). Investigate before you raise the threshold.
-
Let an intended large removal go through. If the drop is expected, set
fail_safe_thresholdhigher for one run. Values must be 100 or less. A value of exactly100.0turns the check off. Set it back after the run. -
Make a run ignore the previous checkpoint. Set
stateful_ingestion.ignore_old_state: truefor one run. The log then reads 'The 'ignore_old_state' config is True. The old checkpoint state will not be provided.' You can also start from no state by using a newpipeline_name. Removeignore_old_stateafterwards. -
Inspect the stored state. Run
datahub state inspect --pipeline-name <name> --platform <platform>. Both options are required. The command reads the latest stateful ingestion state for the pipeline.
On DataHub Cloud, UI-managed sources already get a pipeline_name. If a Cloud-hosted run still fails and you can't see why, contact DataHub Support.