Area: Ingestion Issues
Sub-Area: Platform Instance Removal and Orphaned Entity Cleanup
Applies to: OSS + Cloud
Issue
You removed or renamed a platform instance, for example after you consolidated two Redshift recipes. You hard deleted the platform instance entity through the API. The old instance still shows in the Platform Instance filter in search, and its datasets and containers are still in DataHub.
You Might Be Asking
- Why does a platform instance still show in the UI after I hard deleted it?
- Are the datasets and containers orphaned now? Do I need DataHub Support to clean them up?
- How do I remove a platform instance and every entity in it?
- Does
datahub delete --recursivestill work after I already deleted the platform instance entity? - Will stateful ingestion remove the old entities after I change or remove
platform_instancein my recipe?
Cause
The Platform Instance filter in search lists the values of the platformInstance field on the indexed entities (datasets, containers, and so on). Each of those entities stores its instance in its own dataPlatformInstance aspect. When you delete the platform instance entity, DataHub deletes only that one entity. The datasets and containers that point to the instance stay, so the filter keeps showing it.
No, those datasets and containers are not orphaned. Each one still carries the instance in its own platformInstance field, and the CLI recursive delete finds them by that field. You can remove them yourself with Option 1. You don't need DataHub Support for this.
Search hides soft deleted entities. The instance leaves the filter once no entity that still points to it is visible in search.
Solution
Option 1: Recursive delete with the CLI
The order of deletes does not matter. The CLI deletes every entity whose platformInstance field matches the instance URN, then deletes the instance URN itself. It finds those entities through search, not through the platform instance entity. So it works the same way after you already deleted the platform instance entity.
First run it as a dry run. A dry run lists what it would delete and writes nothing:
datahub delete \
--urn 'urn:li:dataPlatformInstance:(urn:li:dataPlatform:<your-platform>,<your-instance-name>)' \
--recursive \
--hard \
--dry-run
Replace <your-platform> (for example redshift or mysql) and <your-instance-name> with the value that the recipe had in platform_instance.
When the list is right, run the same command without --dry-run. Add --force to skip the confirmation prompts:
datahub delete \
--urn 'urn:li:dataPlatformInstance:(urn:li:dataPlatform:<your-platform>,<your-instance-name>)' \
--recursive \
--hard \
--force
-
--hardremoves the entities from the database for good. You can't undo it. A hard delete also includes entities that are already soft deleted. - Leave out
--hardto soft delete instead. Soft deleted entities leave search and the filter, and you can restore them. -
--recursiveworks only with a single--urnof typecontainerordataPlatformInstance.
See Delete everything within a MySQL platform instance.
Option 2: Stale entity removal with stateful ingestion
Stateful ingestion soft deletes the entities that were in the last successful run but are missing from the current run. A change to platform_instance gives every dataset and container from that recipe a new URN. So the old URNs are "missing" from the next run.
This works only when all of these are true:
- The recipe has a top-level
pipeline_namethat does not change between runs. - Stateful ingestion was already on, and at least one run finished successfully with the old
platform_instancevalue. Turning stateful ingestion on in the same edit that changesplatform_instancegives the run no old state to compare with, so it removes nothing.
The fail safe stops this cleanup by default. fail_safe_threshold defaults to 75. When more than 75 percent of the last run's URNs are missing, the run soft deletes nothing and reports this failure:
Entity difference exceeds fail_safe_threshold; skipping stale entity removal. To update, set stateful_ingestion.fail_safe_threshold in your recipe.
A platform_instance change misses close to 100 percent of the old URNs, so it trips the fail safe. For the one run after the change, set fail_safe_threshold to 100:
pipeline_name: redshift-prod # unique to this recipe; do not change it
source:
type: redshift
config:
# ... connection settings, with the new platform_instance or none ...
stateful_ingestion:
enabled: true
remove_stale_metadata: true
fail_safe_threshold: 100 # for this one run only
After that run succeeds, remove fail_safe_threshold so the fail safe is on again. A value of 100 turns the fail safe off.
That run soft deletes the old datasets and containers. They leave search and the Platform Instance filter. To remove them from the database too, run the Option 1 command with --hard.
See Stale Entity Removal.
Update recipes that point at the old instance
Other recipes can refer to the old instance. For example, a dbt recipe uses target_platform_instance to build the URNs of the warehouse tables it links to. Set it to the new Redshift platform_instance value, or remove it if the Redshift recipe no longer sets one:
source:
type: dbt
config:
# ... other configs ...
target_platform: redshift
target_platform_instance: <your-redshift-platform-instance>
See the dbt source config.
Verify
Open search and check the Platform Instance filter for the platform. The old instance no longer shows once no visible entity points to it.
Related Documentation
- Removing Metadata from DataHub
- Delete everything within a MySQL platform instance
- Working With Platform Instances
- Stateful Ingestion: Stale Entity Removal
- dbt source
Tags: platform-instance, hard-delete, recursive-delete, stateful-ingestion, fail-safe-threshold, redshift, datahub-cli