Area: Ingestion Issues
Sub-Area: Snowflake Connector, Out of Memory During Lineage and Usage Extraction
Applies to: OSS + Cloud
Issue
A Snowflake ingestion run fails because the process runs out of memory. This happens during the lineage, usage and queries stage, when the connector reads SNOWFLAKE.ACCOUNT_USAGE.ACCESS_HISTORY and QUERY_HISTORY and parses every query in the time window. Accounts with a high query volume hit this most often, even when the recipe ingests only one small database.
Error Messages
The run fails with:
Failed to execute 'datahub ingest'
The executor also reports that the process was killed. The wording depends on the executor version:
The ingestion process was killed by signal SIGKILL likely because it ran out of memory. You can resolve this issue by allocating more memory to the datahub-actions container.The ingestion process was killed by signal SIGKILL, most likely because the executor ran out of memory.
If the process exits with code 137 instead of a signal, the message says terminated with exit code 137 in place of killed by signal SIGKILL.
You Might Be Asking
- Why does my Snowflake ingestion run out of memory when the database I ingest has few tables?
- How do I make DataHub read query history only for the databases in my recipe?
- Will more executor memory fix this for good?
Cause
By default, the Snowflake source reads the query log for the whole Snowflake account. database_pattern controls which databases DataHub ingests, but it does not filter the ACCESS_HISTORY query. The connector fetches every query in the time window and drops queries for tables outside your patterns only after it has fetched and processed them. So memory use follows the query volume of the whole account, not the size of the database you ingest.
The push_down_database_pattern_access_history option changes this. When it is true, the connector adds your database_pattern to the ACCESS_HISTORY query in Snowflake, so only queries that touch a matching database come back. It defaults to false.
Solution
-
Upgrade to the latest DataHub CLI version. Run the latest release of the
acryl-datahubCLI in your executor or recipe. The options below exist in the current release. -
Push the database filter down to
ACCESS_HISTORY. Setpush_down_database_pattern_access_history: truetogether withdatabase_patternin your Snowflake recipe:
source:
type: snowflake
config:
# ... connection config ...
database_pattern:
allow:
- "^ANALYTICS$"
push_down_database_pattern_access_history: true
additional_database_names_allowlist:
- "STAGING_TEMP"
How the pushed down filter works:
- Snowflake matches the pattern against the database name in upper case, with
RLIKE. Write the database names in yourallowanddenyentries in upper case. -
RLIKEmatches the full name, not a prefix. Use"^ANALYTICS$"for one database, or"ANALYTICS.*"for a prefix. - A query is kept when it touches at least one database that matches. Queries that touch only other databases are not fetched, so DataHub does not see lineage from them.
- If your ETL tools create temporary tables in a different database, list that database in
additional_database_names_allowlist. It takes exact database names, not patterns, and only applies whenpush_down_database_pattern_access_historyistrue. Without it, DataHub cannot follow lineage through those temporary tables.
See the Snowflake source documentation for every option.
-
Filter out high-volume users. If service accounts run most of your queries, exclude them from query log extraction with
pushdown_deny_usernames. It takes SQLLIKEpatterns:
source:
type: snowflake
config:
pushdown_deny_usernames:
- "SERVICE_%"
pushdown_allow_usernames does the opposite: only the listed users are read. DataHub will have no lineage, usage or queries from the excluded users.
-
Keep the time window at the default. If you don't set
start_time, each run reads from 00:00 UTC of the previous day up to the current time. A recipe withstart_time: "-7d"reads seven days of query history in every run. Remove it unless you need a backfill.A window shorter than one day needs
bucket_duration: HOUR. With the defaultbucket_duration: DAY,start_time: "-12h"fails validation withRelative start time should be in terms of configured bucket duration. WithHOUR, usage statistics are aggregated per hour, and the connector deduplicates repeated queries per hour instead of per day. -
If you run a separate
snowflake-queriesrecipe, turn off query extraction in the main recipe. Thesnowflake-queriessource reads only the query log, for lineage, usage and queries. If you run it next to the mainsnowflakesource, the main source still reads the full query log as long as any one of these options is on:include_table_lineage,include_usage_stats,include_operational_stats,include_queries,include_query_usage_statistics. All five default totrue. Turn all of them off in the main recipe:
source:
type: snowflake
config:
# ... connection and pattern config ...
include_table_lineage: false
include_column_lineage: false
include_usage_stats: false
include_operational_stats: false
include_queries: false
include_query_usage_statistics: false
include_column_lineage must be false when include_table_lineage is false. Do not use include_view_lineage. It was removed from the Snowflake source, and the recipe ignores it with a warning.
Set the push down options in the snowflake-queries recipe too. The time window goes under window:
source:
type: snowflake-queries
config:
connection:
account_id: "<your-snowflake-account-id>"
authentication_type: KEY_PAIR_AUTHENTICATOR
username: "<your-service-account-username>"
private_key: "${SNOWFLAKE_PRIVATE_KEY}"
role: "<your-snowflake-role>"
warehouse: "<your-warehouse>"
window:
start_time: "-1d"
database_pattern:
allow:
- "^ANALYTICS$"
push_down_database_pattern_access_history: true
- Run profiling in its own recipe. Profiling is off by default. If your daily recipe turns it on, move profiling to a separate recipe on a less frequent schedule, so it does not run in the same process as query log extraction:
source:
type: snowflake
config:
profiling:
enabled: false
-
Give the executor enough memory, and don't run large ingestions at the same time. Every ingestion running on an executor shares its memory limit. On a Remote Executor, the number of ingestions that run at once is set by
DATAHUB_EXECUTOR_INGESTION_MAX_WORKERS(default4). In the DataHub provided Helm chart this isdatahub.executor_ingestions_workers. Schedule large warehouse ingestions so they don't overlap, and size memory for the runs that do. On Kubernetes, set the memory request equal to the memory limit so the pod is scheduled on a node that has that memory free. See Remote Executor best practices for sizing guidance. If your ingestion runs on a DataHub hosted executor, contact DataHub Support about executor memory.More memory alone does not fix the cause. Without the push down, memory keeps growing with your account's query volume.
Additional Notes
-
use_file_backed_cachedoes not help here. It already defaults totrue, and it only caches view definitions. - The connector writes the fetched query log to a temporary SQLite file on disk before it processes it. Make sure the executor has enough free disk space under its temporary directory.