Area: Deployment Issues
Sub-Area: GMS Performance / GraphQL Timeout Misconfiguration
Applies to: OSS + Cloud
Issue
After a DataHub upgrade, scripts and pipeline jobs that send GraphQL requests to GMS start to fail with read timeouts. The calls that fail most often are lineage queries such as scrollAcrossLineage, because GMS walks the lineage graph in Elasticsearch or OpenSearch before it returns results.
The DataHub Python client (DataHubGraph) uses a 30 second read timeout by default. GMS lets a lineage graph walk run for up to 50 seconds by default. When a lineage query needs more than 30 seconds, the client gives up first, even though GMS is still working on the answer.
The client also retries. By default it makes up to five attempts (one try plus four retries), and read timeouts on POST requests count as retryable. So one GraphQL call that keeps timing out at 30 seconds takes more than two and a half minutes to fail. Across many entities, job throughput collapses.
Error Messages
These messages come from the requests and urllib3 libraries that the DataHub Python client uses:
Read timed out. (read timeout=30)-
Max retries exceeded with url: /api/graphql(the path includes any prefix in your server URL, for example/gms/api/graphql)
On the GMS side, when a scrollAcrossLineage graph walk runs past the server limit, GMS fails the request and logs:
Timed out while fetching lineage for <urn> with direction <direction>, maxHops <n>. Operation exceeded the configured timeout.
You Might Be Asking
- Why did my job start timing out on GraphQL calls only after a DataHub upgrade?
- Why does each failed lineage query take minutes instead of 30 seconds?
- What is
ELASTICSEARCH_SEARCH_GRAPH_TIMEOUT_SECONDSand how does it relate to my client timeout? - How do I stop the retries from multiplying the delay while I find the root cause?
Solution
Fix this in two parts. First, raise the client timeout so slow lineage queries finish instead of failing and retrying. Then find out why GMS got slower.
Part 1: Set the client read timeout above the GMS lineage timeout
-
Know the GMS lineage limit. The GMS environment variable
ELASTICSEARCH_SEARCH_GRAPH_TIMEOUT_SECONDS(Spring propertyelasticsearch.search.graph.timeoutSeconds) caps the lineage graph walk. The default is 50 seconds. See Environment Variables.This limit covers only the graph walk. After the walk, GMS runs a second search step to build the results, so the full
scrollAcrossLineagecall can take longer than 50 seconds. The limit does not apply to non lineage queries such asscrollAcrossEntities.Self-hosted: check the value in your GMS deployment. DataHub Cloud: you can't change GMS settings. Contact DataHub Support if you need this limit checked or changed.
-
Set your client read timeout above that limit, with room for the search step. For example, with the default 50 second limit, use 90 seconds. Also lower the retry count, because every retry runs the full slow query again.
With the DataHub Python client, set
timeout_secandretry_max_timesonDatahubClientConfig. These are the same fields that thedatahub_apianddatahub-restrecipe sections use. See Recipe Overview.from datahub.ingestion.graph.client import DataHubGraph from datahub.ingestion.graph.config import DatahubClientConfig graph = DataHubGraph( DatahubClientConfig( server="<your-gms-url>", token="<your-access-token>", timeout_sec=90, # above the 50 second GMS lineage limit retry_max_times=1, ) )You can also change the default retry count for every client in a process with the environment variable
DATAHUB_REST_EMITTER_DEFAULT_RETRY_MAX_TIMES(default4).If you call the GraphQL endpoint with plain
requests, pass the timeout on each call, for examplerequests.post(url, json=payload, headers=headers, timeout=90). -
Ask GMS for less work per call. Lineage queries that cover fewer hops finish faster.
scrollAcrossLineagetakes oneinputargument. To limit hops, filter on thedegreefield with values"1","2"or"3+", and keepcountsmall. See GraphQL Best Practices: Lineage Query Best Practices.query = """ query lineage($input: ScrollAcrossLineageInput!) { scrollAcrossLineage(input: $input) { nextScrollId searchResults { degree entity { urn } } } } """ variables = { "input": { "urn": "<your-entity-urn>", "direction": "DOWNSTREAM", "count": 100, "orFilters": [ {"and": [{"field": "degree", "condition": "EQUAL", "values": ["1"]}]} ], } } result = graph.execute_graphql(query, variables=variables)Pass
nextScrollIdback asinput.scrollIdto fetch the next page.
Part 2: Find out why GMS got slower (self-hosted)
DataHub Cloud customers: contact DataHub Support with the failing query, the entity URN and the time window. The steps below need access to your own GMS and Elasticsearch.
-
Check for the OSS v1.4.x ingestion regression. In OSS GMS v1.4.0 through v1.4.0.3, every ingestion write that carries a run ID makes an extra uncached index existence request to Elasticsearch. This adds Elasticsearch load during ingestion. GMS v1.5.0 caches this check. If you run a v1.4.x release, upgrade GMS to the latest release.
-
Check that
ES_BULK_REFRESH_POLICYisNONE.NONEis the default, and it has been since at least v1.3.0. If someone set it toWAIT_UNTILorIMMEDIATEin your GMS or MAE consumer environment, remove the override. The Environment Variables page notes thatWAIT_UNTILcan stall the consumer under load. -
Check Elasticsearch or OpenSearch cluster health. Lineage queries depend on it directly.
curl -X GET "https://<your-elasticsearch-host>:9200/_cluster/health?pretty"A
yelloworredstatus, or nodes under memory pressure, slows every lineage query. -
Check GMS logs for the lineage timeout message from the Error Messages section. If it appears, GMS hit the graph walk limit. Narrow the query (step 3 of Part 1) or raise
ELASTICSEARCH_SEARCH_GRAPH_TIMEOUT_SECONDS. If you raise it, raise your client timeout to match.
Additional Notes
- A lineage query can legitimately need more than 30 seconds on a large graph even when GMS is healthy. Check the client timeout before you conclude that GMS is broken.
- Raising the client timeout stops the failures and the retry delay. It doesn't make GMS faster. If GMS got slower after the upgrade, also work through Part 2.