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
In a nutshell
  • Use TASK_HISTORY (function and view), task graph functions and SERVERLESS_TASK_HISTORY to investigate.
  • Common causes: suspended task, lost privileges, SQL error, timeout, false WHEN, overlapping run.
  • SUSPEND_TASK_AFTER_NUM_FAILURES auto-suspends; TASK_AUTO_RETRY_ATTEMPTS retries.

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.

Task run fails or is skippedQuery TASK_HISTORYstate, error codeFind causeprivilege, SQL, timeout, warehouseFix and RESUME

How it works

Reading task history

Task runs are recorded in several places:

SourceUse
TASK_HISTORY table function (INFORMATION_SCHEMA)Recent runs of a task, with state and errors
SNOWFLAKE.ACCOUNT_USAGE.TASK_HISTORY viewLonger history; compare scheduled, start and completed times
CURRENT_TASK_GRAPHS and COMPLETE_TASK_GRAPHSCurrent and recent graph runs
TASK_VERSIONS (ACCOUNT_USAGE)Which version of the definition ran
SERVERLESS_TASK_HISTORYCredits used by serverless tasks
Snowsight task historyVisual 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

SymptomLikely causeFix
Task never appears in historyStill suspendedALTER TASK ... RESUME
Task not scheduled after a role changeOwner role lost EXECUTE TASK or object privilegesRegrant to the owner role and resume
Run state failed with SQL errorThe statement itself errorsTest the SQL by hand with the owner role
Run skippedWHEN condition false (stream empty), or previous run still activeExpected behavior; check overlap and run time
Run failed on timeoutLong statement against USER_TASK_TIMEOUT_MS or statement timeoutRaise limit, resize or tune the query
Warehouse errorWarehouse dropped, or owner has no USAGEFix the warehouse reference or privilege
Graph stoppedPredecessor failed, or auto-suspended after repeated failuresFix, 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.

Exam tip

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 caseWhy a task
Incremental ELT from a streamWHEN SYSTEM$STREAM_HAS_DATA runs only when there is new data
Scheduled housekeepingPurge old rows, refresh summary tables
Pipeline with dependenciesTask graph with AFTER and a finalizer
Calling stored procedures on a timerRun code in Snowpark or SQL scripting
Periodic data quality or alert checksQuery 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

AspectUser-managedServerless (Snowflake-managed)
ComputeNamed warehouse set in WAREHOUSENo warehouse; Snowflake provisions it
SizingYou pick the sizeSnowflake sizes from run history
First run sizeYour warehouseUSER_TASK_MANAGED_INITIAL_WAREHOUSE_SIZE sets it before history exists
Limits you setWarehouse sizeSERVERLESS_TASK_MIN_STATEMENT_SIZE (default XSMALL) and SERVERLESS_TASK_MAX_STATEMENT_SIZE (default X2LARGE)
BillingWarehouse credits, 60 second minimum per startServerless compute used by the task, shown in SERVERLESS_TASK_HISTORY
Extra privilegeUSAGE on the warehouseEXECUTE MANAGED TASK
Resource monitorsCan suspend the warehouseDo not apply to serverless tasks
Task workloadSteady, many tasks sharing a warehouse?User managedshared warehouse stays warmTask workloadIrregular or short runs?Serverlessno idle warehouse

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 and SERVERLESS_TASK_HISTORY to investigate.
  • Common causes: suspended task, lost privileges, SQL error, timeout, false WHEN, overlapping run.
  • SUSPEND_TASK_AFTER_NUM_FAILURES auto-suspends; TASK_AUTO_RETRY_ATTEMPTS retries.
  • 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_FAILURES auto-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.