Area: Ingestion Issues
Sub-Area: dbt Ingestion / Stateful Ingestion Configuration
Applies to: OSS + Cloud
Issue
You run two or more dbt recipes with stateful ingestion, and the recipes use the same pipeline_name. Each run soft deletes models that belong to the other recipe. The next run of the other recipe brings them back. Entities keep switching between removed and present, and every run sends extra writes to DataHub.
Other symptoms you can see:
- The run report lists many entities under
soft_deleted_stale_entities. - A run fails with this message:
Skipping stateful ingestion / stale entity removal
Entity difference exceeds fail_safe_threshold; skipping stale entity removal. To update, set stateful_ingestion.fail_safe_threshold in your recipe.
- When DataHub refuses writes because of a rate limit, the run fails with this error after its retries run out:
'Unable to emit metadata to DataHub GMS: None', {'error': 'Rate limit exceeded'}
You Might Be Asking
- Why does stateful ingestion keep soft deleting dbt models that still exist?
- How should I name my ingestion pipelines so stateful ingestion works?
- Why does my dbt ingestion fail with
Rate limit exceeded? - How can I check whether DataHub is behind on processing my writes?
Cause
Stateful ingestion saves the list of URNs that each run ingests. DataHub stores this state against the recipe's top-level pipeline_name and a job name. Every dbt recipe uses the same job name, so two dbt recipes with the same pipeline_name read and overwrite one state.
With stateful_ingestion.enabled: true, remove_stale_metadata is on by default. Each run soft deletes the URNs that were in the stored state but are missing from this run. When two recipes share a pipeline_name, the stored state comes from the other recipe:
- Recipe A runs. It compares its URNs with recipe B's state and soft deletes B's entities.
- Recipe B runs. It marks its own entities as present again, then soft deletes A's entities.
This repeats on every run. Each soft delete and each restore is one write to DataHub, so a large dbt project produces many extra writes per run.
If more than fail_safe_threshold percent of the stored URNs are missing (75 by default), the run does not soft delete anything. It fails with the fail_safe_threshold message shown above.
A dbt recipe and a recipe for a different source type (for example Snowflake) use different job names. They do not overwrite each other's state even with the same pipeline_name.
Solution
1. Give every recipe its own pipeline_name
Set a top-level pipeline_name that is unique to the recipe, and keep it the same between runs. Do not use one pipeline_name for two recipes that ingest different dbt projects, targets or node subsets.
pipeline_name: dbt_prod_marketing # unique to this recipe; do not change it
source:
type: dbt
config:
manifest_path: <path-to-manifest.json>
catalog_path: <path-to-catalog.json>
target_platform: snowflake # required; the platform your dbt project runs on
stateful_ingestion:
enabled: true
# remove_stale_metadata is true by default.
# fail_safe_threshold is 75 by default.
sink:
type: datahub-rest
config:
server: <your-datahub-gms-url>
token: <your-datahub-token>
To also load test results, add run_results_paths as a list, for example run_results_paths: ["<path-to-run_results.json>"].
The pipeline_name rules are in Recipes: Pipeline name. The dbt config keys are in the dbt source reference.
2. Find recipes that share a name
- Sources that you create in the DataHub UI get a
pipeline_nameautomatically when the recipe does not set one. These names are already unique. - A collision happens when you set
pipeline_nameyourself, for example in a copied recipe, or in recipes you run with thedatahub ingestCLI. - Open the recipe of each dbt source in the DataHub UI, and each dbt recipe file you run with the CLI. Look for the same
pipeline_nameon two dbt recipes.
3. Rename the conflicting recipes
Change the pipeline_name on one or both recipes so each one is unique.
- The first run under a new name finds no stored state. It soft deletes nothing and stores a new state for the next run.
- On that run, each recipe also marks its own entities as present again, so entities the other recipe soft deleted come back.
- Stateful ingestion never removes URNs that only exist in the state under the old name. If a model is gone from your dbt project, soft delete it yourself.
The settings are in Stateful Ingestion: Stale Entity Removal.
4. Reduce write pressure when DataHub returns 429
The datahub-rest sink already retries HTTP 429 with exponential backoff. The Rate limit exceeded error above appears only after the retries run out. To lower the load and give DataHub time to recover:
- Fix any shared
pipeline_namefirst, so runs stop soft deleting and restoring the same entities. - Do not start many large recipes at the same time. Spread their schedules apart, and do not trigger the same recipe twice in a short window.
- Lower the number of parallel write threads in the sink (15 by default), or raise the number of retries:
sink:
type: datahub-rest
config:
server: <your-datahub-gms-url>
token: <your-datahub-token>
max_threads: 5
retry_max_times: 8
These keys are listed in the DataHub sink reference. If you write metadata with the Python SDK, DatahubRestEmitter accepts the same retry_max_times and retry_status_codes arguments.
On DataHub Cloud, DataHub sets the server rate limits. If your runs still get 429 errors after these steps, contact DataHub Support.
5. Check how far behind DataHub is
DataHub Cloud v2.1.0 and later, and DataHub v1.8.0 and later, report the lag of the metadata change proposal consumer. The call needs a token for a user with the View System Status privilege.
curl -X GET \
'https://<your-datahub-url>/openapi/operations/messaging/mcp/consumer/lag?skipCache=false&detailed=true' \
-H 'accept: application/json' \
-H 'Authorization: Bearer <your-datahub-token>'
The response lists each consumer group and topic with maxLag, medianLag, totalLag and avgLag. A totalLag that keeps growing while your dbt runs report many soft deleted entities points to the shared pipeline_name problem.
Related Documentation
- Recipes: Pipeline name
- Stateful Ingestion
- Stateful Ingestion: Stale Entity Removal
- dbt source reference
- DataHub sink reference
Tags: dbt, stateful-ingestion, pipeline-name, soft-deletion, rate-limiting, http-429, mcp, dbt-ingestion-configuration