Data and Object Management · Topic 9 of 11
Tasks - Troubleshooting, Use Cases and Serverless Versus User-Managed
Troubleshoot task runs with TASK_HISTORY, know where tasks fit, and choose between user-managed tasks and Snowflake-managed serverless tasks.
- 4 min
- Use
TASK_HISTORY(function and view), task graph functions andSERVERLESS_TASK_HISTORYto investigate. - Common causes: suspended task, lost privileges, SQL error, timeout, false
WHEN, overlapping run. SUSPEND_TASK_AFTER_NUM_FAILURESauto-suspends;TASK_AUTO_RETRY_ATTEMPTSretries.
What it is
Once tasks run, the administrator has two jobs: find out why a run failed or did not happen, and decide which compute model each task should use.
A user-managed task runs on a virtual warehouse you name. A Snowflake-managed (serverless) task runs on compute that Snowflake sizes and bills for. The choice changes cost, control and the privileges needed.
How it works
Reading task history
Task runs are recorded in several places:
| Source | Use |
|---|---|
TASK_HISTORY table function (INFORMATION_SCHEMA) | Recent runs of a task, with state and errors |
SNOWFLAKE.ACCOUNT_USAGE.TASK_HISTORY view | Longer history; compare scheduled, start and completed times |
CURRENT_TASK_GRAPHS and COMPLETE_TASK_GRAPHS | Current and recent graph runs |
TASK_VERSIONS (ACCOUNT_USAGE) | Which version of the definition ran |
SERVERLESS_TASK_HISTORY | Credits used by serverless tasks |
| Snowsight task history | Visual list of runs and graphs |
SELECT name, state, scheduled_time, error_code, error_message
FROM TABLE(INFORMATION_SCHEMA.TASK_HISTORY(
TASK_NAME => 'LOAD_ORDERS',
RESULT_LIMIT => 20))
ORDER BY scheduled_time DESC;
Run states include scheduled, executing, succeeded, failed, skipped and cancelled. To see history you need ACCOUNTADMIN, ownership of the task or the global MONITOR EXECUTION privilege.
Typical causes
| Symptom | Likely cause | Fix |
|---|---|---|
| Task never appears in history | Still suspended | ALTER TASK ... RESUME |
| Task not scheduled after a role change | Owner role lost EXECUTE TASK or object privileges | Regrant to the owner role and resume |
| Run state failed with SQL error | The statement itself errors | Test the SQL by hand with the owner role |
| Run skipped | WHEN condition false (stream empty), or previous run still active | Expected behavior; check overlap and run time |
| Run failed on timeout | Long statement against USER_TASK_TIMEOUT_MS or statement timeout | Raise limit, resize or tune the query |
| Warehouse error | Warehouse dropped, or owner has no USAGE | Fix the warehouse reference or privilege |
| Graph stopped | Predecessor failed, or auto-suspended after repeated failures | Fix, then resume |
SUSPEND_TASK_AFTER_NUM_FAILURES suspends a task after that many consecutive failed or timed-out runs. A value above 0 enables it. A task that is "mysteriously off" may have suspended itself this way. TASK_AUTO_RETRY_ATTEMPTS can retry a failed run before it counts as failed in the graph.
First check the state column, then the error code and message, then the owner role privileges. Most task failures are privileges or the SQL itself.
Use cases
| Use case | Why a task |
|---|---|
| Incremental ELT from a stream | WHEN SYSTEM$STREAM_HAS_DATA runs only when there is new data |
| Scheduled housekeeping | Purge old rows, refresh summary tables |
| Pipeline with dependencies | Task graph with AFTER and a finalizer |
| Calling stored procedures on a timer | Run code in Snowpark or SQL scripting |
| Periodic data quality or alert checks | Query and write results |
For purely declarative transformations, a dynamic table may fit better than a task. Tasks fit when you need procedural steps or a fixed schedule.
User-managed versus Snowflake-managed
| Aspect | User-managed | Serverless (Snowflake-managed) |
|---|---|---|
| Compute | Named warehouse set in WAREHOUSE | No warehouse; Snowflake provisions it |
| Sizing | You pick the size | Snowflake sizes from run history |
| First run size | Your warehouse | USER_TASK_MANAGED_INITIAL_WAREHOUSE_SIZE sets it before history exists |
| Limits you set | Warehouse size | SERVERLESS_TASK_MIN_STATEMENT_SIZE (default XSMALL) and SERVERLESS_TASK_MAX_STATEMENT_SIZE (default X2LARGE) |
| Billing | Warehouse credits, 60 second minimum per start | Serverless compute used by the task, shown in SERVERLESS_TASK_HISTORY |
| Extra privilege | USAGE on the warehouse | EXECUTE MANAGED TASK |
| Resource monitors | Can suspend the warehouse | Do not apply to serverless tasks |
Choose serverless for short, infrequent or unpredictable tasks, so no warehouse sits idle. Choose user-managed when many tasks run close together and can share one warm warehouse, when you need a fixed size or when a resource monitor must cap the spend. Very frequent tasks on a warehouse can keep it from suspending and cost credits all day.
A serverless task can be given a TARGET_COMPLETION_INTERVAL to guide how fast Snowflake sizes it.
Common mistakes
Reading only the latest row. A skipped run is not an error; read the state and the reason.
Forgetting EXECUTE MANAGED TASK for serverless. Creation fails without it.
Running a one-minute task on a large warehouse. The warehouse never suspends. Use serverless or a small warehouse.
Ignoring auto-suspend after failures. The task stays off until someone resumes it.
Expecting resource monitors to cap serverless tasks. Track those credits through SERVERLESS_TASK_HISTORY instead.
What to remember for the exam
- Use
TASK_HISTORY(function and view), task graph functions andSERVERLESS_TASK_HISTORYto investigate. - Common causes: suspended task, lost privileges, SQL error, timeout, false
WHEN, overlapping run. SUSPEND_TASK_AFTER_NUM_FAILURESauto-suspends;TASK_AUTO_RETRY_ATTEMPTSretries.- Serverless: no warehouse,
EXECUTE MANAGED TASK, sizes between min and max statement size. - User-managed: warehouse you size and pay for.
Check yourself
Which view shows credits used by serverless tasks?
SERVERLESS_TASK_HISTORY.A task stopped running after several failures and nobody changed it. Why?
SUSPEND_TASK_AFTER_NUM_FAILURESauto-suspended it; fix the cause and resume it.When is serverless a better fit than a user-managed task?
For short, infrequent or irregular runs, where an idle warehouse would waste credits.
Topic 9 of 11 in Data and Object Management
Test yourself on Data and Object Management
The full Snowflake ADA-C02 question bank has 814 questions, with timed practice exams and an explanation for every answer.
This study guide is independent and is not affiliated with, endorsed by, or sponsored by Snowflake. Vendor names, certification names and exam codes are trademarks of their respective owners and are used for identification only.