Area: Ingestion Issues
Sub-Area: Memory Management
Applies to: OSS + Cloud
Issue
You run many Teradata ingestion recipes, one after another or side by side, in the same Python process or Kubernetes pod. You start them with the datahub CLI or with the Python Pipeline API. Memory use climbs with each recipe and does not drop when a recipe finishes. In the end the pod is killed with the Kubernetes status OOMKilled. This is most visible on large Teradata systems with many databases and views.
You Might Be Asking
- Why does memory keep growing after a recipe completes?
- How do I stop OOM crashes during large Teradata ingestions?
- Which recipe settings lower memory use for Teradata?
Cause
Three things drive the growth:
- Older releases of the Teradata source kept table and view metadata in a cache shared by every run in the process, and kept schema column, primary key and foreign key lookups in module level caches. Nothing cleared them when a recipe finished, so each recipe in the same process added to the memory the last one left behind. Current releases clear these caches when the source closes, and the ingestion pipeline closes the source at the end of every run.
- If you don't set
databases, the connector loads table and view metadata for every database on the Teradata system, not only the ones you ingest. On large systems this is the main cause of OOM crashes. - The compiled C extension of sqlglot, the SQL parser that view lineage uses, has leaked memory in the past.
Solution
1. Upgrade the DataHub CLI
Upgrade acryl-datahub to the latest release. Current releases clear the Teradata caches at the end of each run, push the databases filter into the metadata query, and support the DATAHUB_SQLGLOT_DISABLE_C switch described below.
pip install --upgrade 'acryl-datahub[teradata]'
2. Run each recipe in its own process
When a process exits, the operating system takes back all of its memory. Running each recipe as a separate datahub ingest process is the most reliable way to keep memory flat across many recipes. This script runs four recipes at a time, each in its own process:
import concurrent.futures
import glob
import subprocess
import sys
def run_recipe(recipe_file: str) -> int:
result = subprocess.run(
[sys.executable, "-m", "datahub", "ingest", "run", "-c", recipe_file]
)
return result.returncode
if __name__ == "__main__":
recipe_files = sorted(glob.glob("/app/recipes/teradata_*.yml"))
with concurrent.futures.ThreadPoolExecutor(max_workers=4) as executor:
futures = {executor.submit(run_recipe, f): f for f in recipe_files}
for future in concurrent.futures.as_completed(futures):
recipe_file = futures[future]
code = future.result()
status = "Completed" if code == 0 else f"Failed (exit code {code})"
print(f"{status}: {recipe_file}")
datahub ingest run exits with a non-zero code when the run fails, so the script reports each failed recipe.
3. Lower memory use in the recipe
Put these settings together under one source.config block. See the Teradata source documentation for every option.
source:
type: teradata
config:
host_port: "myteradatainstance.teradata.com:1025"
username: myuser
password: mypassword
# Load metadata only for these databases
databases:
- sales_db
- finance_db
# Fewer parallel view workers (default is 10)
max_workers: 4
# Skip view lineage if you don't need it (default is true)
include_view_lineage: false
-
databaseslimits the metadata query to the listed databases, so the connector does not hold metadata for the rest of the system. -
max_workerssets how many threads process views in parallel. The default is 10. Fewer workers means less work in memory at once. The Teradata troubleshooting section gives the same advice forOOMKilledpods. -
include_view_lineage: falsestops the connector from parsing view SQL for lineage. You lose view lineage.
4. Turn off the sqlglot C extension
If memory still grows while the connector parses view or query SQL, set this environment variable on the process or pod that runs ingestion:
DATAHUB_SQLGLOT_DISABLE_C=1
DataHub then loads the pure Python version of sqlglot and skips the compiled C extension. SQL parsing runs slower.
5. Give the pod more memory
If the pod still hits its limit after the steps above, raise the memory limit on the pod that runs ingestion.