Area: Observability Issues
Sub-Area: Assertion Monitors / Volume Anomaly Detection
Applies to: Cloud
Issue
Your Snowflake warehouse alerts on long-running queries from the user DataHub connects as. You have Volume assertions (including Volume Anomaly Detection) on the affected table, so the assertions look like the cause. Stopping assertions or Monitoring Rules doesn't seem to help.
DataHub Cloud sends two kinds of queries to Snowflake, and both use the connection from your Snowflake ingestion source:
- Assertion queries from Observe, which check your assertions on their schedule.
- Ingestion queries, including profiling, which run when your Snowflake ingestion source runs.
You need to know which one is running before you change anything.
You Might Be Asking
- Are these long-running Snowflake queries coming from assertions or from ingestion profiling?
- How do I find the assertion that sent a query?
- Why do queries keep running after I stopped my assertions and Monitoring Rules?
- Can I cancel a DataHub query that is already running in Snowflake?
- How do I stop profiling one large table without dropping it from DataHub?
- How do I make a Volume assertion cheaper on a very large table?
Cause
The two kinds of queries look different:
- A Volume assertion with the Query Volume Source runs
SELECT COUNT(*)on the table, with aWHEREclause when you set a filter or time-series bucketing. With the Information Schema Volume Source it reads the row count fromINFORMATION_SCHEMA.TABLESand doesn't touch the table. - Every Observe query starts with a SQL comment such as
/* query_source=datahub_observe assertion_urn=urn:li:assertion:... */. On Snowflake, Observe also sets a sessionQUERY_TAGwith the samequery_sourceandassertion_urnvalues. See Assertion Query Attribution. - Observe queries on Snowflake time out after 10 minutes by default (see the DataHub Cloud v1.0.0 release notes). On a Remote Executor you run yourself, the
DATAHUB_EXECUTOR_SNOWFLAKE_TIMEOUTenvironment variable sets this limit in seconds. The default is600. If a query with thedatahub_observetag runs longer than 10 minutes and you don't run your own executor, contact DataHub Support. Include the Snowflake query ID, theassertion_urnfrom the query tag and the query's start time. - Ingestion profiling queries have no
datahub_observecomment or tag. The Snowflake profiler usesAPPROX_COUNT_DISTINCTfor unique counts andMEDIANfor medians. It also creates temporary sample tables nameddh_sample_<id>. Observe never sends these.
So a multi-hour query with APPROX_COUNT_DISTINCT, MEDIAN or a dh_sample_ table and no datahub_observe tag comes from ingestion, not from a Volume assertion. Stopping assertions has no effect on ingestion queries, and stopping profiling has no effect on assertion queries.
Solution
-
Find the source of each query. Run this in Snowflake as a role that can see the DataHub user's queries.
INFORMATION_SCHEMA.QUERY_HISTORY_BY_USERneeds a current database in your session.SELECT query_id, query_tag, execution_status, start_time, total_elapsed_time, LEFT(query_text, 300) AS query_start FROM TABLE(information_schema.query_history_by_user( USER_NAME => '<your-datahub-snowflake-user>', RESULT_LIMIT => 1000 )) WHERE query_text ILIKE '%<YOUR_TABLE_NAME>%' ORDER BY total_elapsed_time DESC;A
query_tagthat containsdatahub_observemeans an assertion sent the query, and theassertion_urnvalue tells you which one. An emptyquery_tagtogether withAPPROX_COUNT_DISTINCT,MEDIANordh_sample_in the text means ingestion profiling sent it. -
If the queries come from an assertion, stop it. Stopping an assertion stops future evaluations. It doesn't cancel a query that is already running.
- For an assertion you created on the table: open the table's Quality tab, click Volume, and click Stop on the assertion. See Stopping a Volume Assertion.
- For an assertion a Monitoring Rule created: open the Data Health Dashboard and click Monitoring Rules. Change the rule's search predicate so the table no longer matches, and DataHub stops and removes that rule's assertions on the table. Stopping the whole rule stops every assertion the rule created. Managing rules needs the
Manage Testsplatform privilege. See Monitoring Rules.
-
If you want to keep volume monitoring on a very large table, use a cheaper Volume Source. Information Schema reads Snowflake's stored row count instead of running
COUNT(*)on the table. The row count can lag a little behind recent changes. Stop the Query-based assertion and create a new Volume assertion; in the assertion builder, click Advanced and set the Volume Source to Information Schema. Time-series bucketing works only with the Query source, so an assertion that needs bucketing must stay on Query. See Volume Source. -
If the queries come from profiling, exclude the table from profiling. Add
profile_patternto your Snowflake ingestion recipe.profile_patternsits directly underconfig, next toprofiling, not inside it. Theprofilingblock rejects unknown keys, so aprofile_patternnested inside it fails recipe validation.source: type: snowflake config: # ... connection and other settings ... profile_pattern: deny: - "my_db\\.my_schema\\.my_large_table$" profiling: enabled: trueThe pattern matches
database.schema.tableand ignores case by default. Useprofile_pattern, nottable_pattern.table_patternstops ingesting the table at all, so its schema, lineage and usage stop updating in DataHub.Other profiling settings that cut cost:
-
profiling.profile_table_size_limit(default5, in GB) andprofiling.profile_table_row_limit(default5000000). Tables above either limit get table-level profiling only, with no column statistics. If you set either tonull, large tables get full column profiling. -
profiling.profile_table_level_only: trueturns off all column-level statistics for every table. -
profiling.turn_off_expensive_profiling_metrics: trueturns off quantiles, distinct value frequencies, histograms and sample values, and profiles at most 10 columns per table. It does not turn off median or standard deviation. To drop those, setprofiling.include_field_median_value: falseandprofiling.include_field_stddev_value: false.
See the Snowflake source configuration.
-
-
Cancel a running query if you need to. Volume assertion queries are read-only
SELECTstatements. The profiler only reads your tables; it writes nothing but its own session temporary sample tables. Cancelling either one doesn't change your data. A cancelled assertion query fails that one evaluation, and the next scheduled evaluation runs as usual if the assertion is still started.SELECT SYSTEM$CANCEL_QUERY('<query_id>'); -
Check the result. After the next assertion schedule or ingestion run, run the query from step 1 again. Confirm that no new long-running queries from the DataHub user appear against the table.