Area: Ingestion Issues
Sub-Area: Structured Properties / Async Write Queue
Applies to: OSS + Cloud
Issue
You add or change structured properties while a large ingestion run (for example BigQuery or Snowflake) is in progress. The values take a long time, sometimes hours, to show in DataHub. Search results and search filters on the property can also lag behind. It looks like the writes were lost.
You Might Be Asking
- Why do structured properties take hours to appear even though my script or ingestion run succeeded?
- Are my structured property writes lost, or only delayed?
- How do I check whether a structured property value is saved?
- How do I make structured property writes skip the ingestion queue?
- Why does the value show on the asset but not in search?
Cause
DataHub saves a change in two steps:
- GMS saves the aspect to the database.
- GMS sends a Metadata Change Log (MCL) event to Kafka. A consumer reads it and updates the search index. See Serving Tier.
A write is sync or async. For a sync write, GMS saves the aspect to the database before the call returns. For an async write, GMS puts the proposal on a Kafka topic and returns at once. A consumer saves it to the database later. Async proposals wait in line behind all other async proposals.
Ingestion recipes that use the datahub-rest sink send async writes by default. The sink's default mode is ASYNC_BATCH. A large ingestion run puts many proposals in the queue. A structured property write sent async waits behind them, so the database write itself is delayed. The write is not lost. It is saved when the consumer reaches it. Async structured property writes come from:
- an ingestion recipe that sets structured properties, for example with a transformer,
- a script that passes
emit_mode=EmitMode.ASYNCorEmitMode.ASYNC_WAIT, - a script that runs with the environment variable
DATAHUB_EMIT_MODEset toASYNCorASYNC_WAIT.
A sync write skips the proposal queue. In the Python SDK, emit() is sync (EmitMode.SYNC_PRIMARY) unless you change it. The search index still updates from the MCL after the write. During a large run, search results and search filters can lag even for sync writes.
Solution
-
Check whether the value is saved in the database.
With the Python SDK,
get_aspectreads the latest saved aspect. It returnsNonewhen the aspect does not exist:from datahub.ingestion.graph.client import DataHubGraph, DatahubClientConfig from datahub.metadata.schema_classes import StructuredPropertiesClass graph = DataHubGraph( DatahubClientConfig(server="https://<your-instance>.acryl.io/gms", token="<your-token>") ) dataset_urn = "urn:li:dataset:(urn:li:dataPlatform:bigquery,<project>.<dataset>.<table>,PROD)" print(graph.get_aspect(dataset_urn, StructuredPropertiesClass))Or call the REST endpoint with the URL-encoded URN:
GET <your-gms-url>/aspects/<url-encoded-urn>?aspect=structuredProperties&version=0- If the value is there, the write is saved. Only the search index is behind. It catches up when the consumer processes the MCL.
- If the aspect is missing (
None, or HTTP 404) and you sent the write async during a large run, the proposal can still be in the queue. Check again after the run ends. Sending it again now only adds to the queue.
-
Send structured property writes sync, as a patch.
A patch changes only the property you name. The other structured properties on the asset stay as they are.
EmitMode.SYNC_PRIMARYsaves the value to the database before the call returns:from datahub.emitter.rest_emitter import EmitMode from datahub.ingestion.graph.client import DataHubGraph, DatahubClientConfig from datahub.specific.dataset import DatasetPatchBuilder graph = DataHubGraph( DatahubClientConfig(server="https://<your-instance>.acryl.io/gms", token="<your-token>") ) dataset_urn = "urn:li:dataset:(urn:li:dataPlatform:bigquery,<project>.<dataset>.<table>,PROD)" patch = DatasetPatchBuilder(dataset_urn).set_structured_property( "urn:li:structuredProperty:<property-id>", "<value>" ) for mcp in patch.build(): graph.emit(mcp, emit_mode=EmitMode.SYNC_PRIMARY)-
emit()has noasync_flagargument.emitter.emit(mcp, async_flag=False)fails with aTypeError. Useemit_mode. - Do not build a new
StructuredPropertiesClasswith one property and emit it as a whole aspect. That replaces the aspect and removes every other structured property value on the asset. - Make sure
DATAHUB_EMIT_MODEis not set toASYNCorASYNC_WAITwhere the script runs.
For more patch examples, see Patch Structured Property Value.
-
-
If a recipe writes your structured properties, run it as its own recipe with sync writes. Set the sink mode to
SYNC:sink: type: datahub-rest config: server: "https://<your-instance>.acryl.io/gms" token: "<your-token>" mode: SYNCIn
SYNCmode the sink sends one record at a time and waits for each one. Keep large connector recipes on the defaultASYNC_BATCH. See DataHub Rest sink. -
If you call the REST API directly, send
asyncin the JSON body ofPOST <your-gms-url>/aspects?action=ingestProposal, next toproposal:{"proposal": {...}, "async": "false"}. It is not a query parameter. -
If the value is saved but search is still wrong after the ingestion run ends, sending the same value again does not fix it. By default GMS emits no MCL when a write does not change the aspect, so the search index gets no update.
- On self-hosted DataHub, rebuild the search index for the affected entity with the restore indices API:
POST <your-gms-url>/operations?action=restoreIndiceswith{"urn": "<entity urn>", "aspect": "structuredProperties"}. The caller needs theRestore Indices APIprivilege. See Restore Indices Endpoint and Search and Graph Reindexing. - On DataHub Cloud, contact DataHub Support with the entity URNs.
- On self-hosted DataHub, rebuild the search index for the affected entity with the restore indices API:
-
On DataHub Cloud, if large ingestion runs keep delaying your writes, contact DataHub Support.
Related Documentation
- Structured Properties overview
- Structured Properties API tutorial
- DataHub Rest sink
- Serving Tier
- Restore Indices Endpoint
- Search and Graph Reindexing
Tags: structured-properties, async-queue, ingestion-delay, emit-mode, search-index-lag, sync-writes, patch, metadata-change-proposal