Area: API Issues
Sub-Area: Timeline API Performance
Applies to: OSS + Cloud
Issue
Calls to the Timeline API (GET /openapi/v2/timeline/v1/{urn}) are slow or time out for some datasets, while the same call returns fast for others. The slow calls usually ask for the full change history with startTime=0, and the slow datasets usually have large schemas (many columns, or deeply nested structs).
Error Messages
The DataHub Python SDK and the datahub timeline CLI command use a 30 second request timeout by default. When the server takes longer, the Python requests library fails with a read timeout like this:
Read timed out. (read timeout=30)
You Might Be Asking
- Why does the Timeline API time out for only some datasets?
- Is
startTime=0safe to use for every dataset? - Does running ingestion less often, or turning on stateful ingestion, reduce the number of schema versions?
Cause
The time range decides how much history the server reads.
-
startTime=0means "from the beginning".endTime=0(or noendTime) means "now". SostartTime=0reads every stored version of the asset. - If you leave out
startTime, the server uses a 7 day window ending atendTime. - The server reads every stored version, in that time range, of all the dataset's versioned (non timeseries) aspects. The
categoriesyou pass only control which changes it compares and returns. They don't shrink this read. - For datasets, the
TECHNICAL_SCHEMA,TAGandDOCUMENTATIONcategories all compareschemaMetadataversions against each other.
schemaMetadata holds the full list of schema fields. A wide or deeply nested schema makes every stored version large. A full history call on that dataset loads and compares many large versions, so it runs much longer than the same call on a small dataset.
DataHub's default retention policy keeps the latest 20 versions of each aspect, so the history per aspect stays bounded. If a self-hosted deployment changed or turned off retention, history can grow well beyond that.
DataHub only writes a new aspect version when the content changes. Re-ingesting an identical schema doesn't add a version. Running ingestion less often doesn't reduce history for a schema that doesn't change.
Solution
-
Confirm the time range is the problem.
Call the same dataset twice: once with
startTime=0, and once withoutstartTime(the 7 day default). If the bounded call is fast and the full history call is slow, this article applies. URL-encode the URN in the path.curl -s -o /dev/null -w '%{time_total}\n' \ -H 'Authorization: Bearer <your-api-token>' \ 'https://<your-datahub-host>/openapi/v2/timeline/v1/<url-encoded-dataset-urn>?categories=TECHNICAL_SCHEMA&startTime=0' curl -s -o /dev/null -w '%{time_total}\n' \ -H 'Authorization: Bearer <your-api-token>' \ 'https://<your-datahub-host>/openapi/v2/timeline/v1/<url-encoded-dataset-urn>?categories=TECHNICAL_SCHEMA' -
Query a bounded time window instead of
startTime=0.Pass
startTimeandendTimein epoch milliseconds, and ask only for the categories you need. See the Timeline API guide for the categories and the response format. This example reads the last 7 days and sets a longer read timeout:import time from urllib.parse import quote import requests DATAHUB_URL = "https://<your-datahub-host>" TOKEN = "<your-api-token>" urn = "urn:li:dataset:(urn:li:dataPlatform:snowflake,db.schema.table,PROD)" end_time = int(time.time() * 1000) start_time = end_time - 7 * 24 * 60 * 60 * 1000 # last 7 days response = requests.get( f"{DATAHUB_URL}/openapi/v2/timeline/v1/{quote(urn, safe='')}", params={ "startTime": start_time, "endTime": end_time, "categories": ["TECHNICAL_SCHEMA", "TAG"], "raw": "false", }, headers={"Authorization": f"Bearer {TOKEN}"}, timeout=(10, 120), # (connect, read) seconds ) response.raise_for_status() print(len(response.json()), "change transactions")With the CLI, use
--startto bound the window:datahub timeline --urn "<dataset-urn>" -c TECHNICAL_SCHEMA -c TAG --start 30daysagoIf you need older history, walk back in several bounded windows rather than one
startTime=0call. -
Raise the client read timeout for full history calls you can't avoid.
Retrying a request that always takes longer than the timeout fails the same way each time. Set a read timeout longer than the call takes, as in the
timeout=(10, 120)example above. -
Check how many versions the dataset holds (self-hosted).
Run this read-only query against the DataHub SQL database:
SELECT aspect, COUNT(*) AS versions FROM metadata_aspect_v2 WHERE urn = '<dataset-urn>' GROUP BY aspect ORDER BY versions DESC;With default retention, each aspect has at most about 20 rows. Much higher counts mean retention was changed or turned off. See Configuring Database Retention to review your retention policy.
-
On DataHub Cloud, contact DataHub Support if a bounded window is still slow.
Include the dataset URN, the exact request (time range and categories), and how long it takes.