Troubleshooting Tasks

This section describes a methodical approach to troubleshooting tasks that do not run as expected.

In this Topic:

Task Did Not Run

Step 1: Verify the Task Did Not Run

Query the TASK_HISTORY table function to verify the task did not run. It is possible that the task ran successfully but the SQL statement in the task definition failed. In particular, note the scheduled and completed times, as well as any error code and message.

If the task has a parent task (in a tree of tasks), verify whether the parent task completed successfully.

Step 2: Verify the Task was Resumed

Verify the state of the task (or each task in a tree of tasks) is RESUMED (using DESCRIBE TASK or SHOW TASKS).

To resume an individual task, execute ALTER TASK … RESUME. To recursively enable all dependent tasks tied to a root task, query the SYSTEM$TASK_DEPENDENTS_ENABLE function rather than enabling each task individually.

While you are reviewing the task details, if the task has a schedule, also check the cron expression. Verify that at least one occurrence of the scheduled time has passed.

Step 3: Verify the Permissions Granted to the Task Owner

Verify the task owner (i.e. the role that has the OWNERSHIP privilege on the task) has the global EXECUTE TASK privilege (using SHOW GRANTS TO ROLE role_name). This privilege is required to execute tasks.

If the role does not have the EXECUTE TASK privilege, assign the privilege as an account administrator (user with the ACCOUNTADMIN role), e.g.:

USE ROLE accountadmin;

GRANT EXECUTE TASK ON ACCOUNT TO ROLE <role_name>;

Step 4: Verify the Condition

If the task includes a WHEN clause with a SYSTEM$STREAM_HAS_DATA condition, verify that the specified stream contained change data capture (CDC) records when the task was last scheduled to run. Historical data for a stream can be queried using an AT | BEFORE clause.

Task Timed out or Exceeded the Schedule Window

There is a 60 minute default limit on a single run of a task. This limitation was implemented as a safeguard against non-terminating tasks. Query the TASK_HISTORY table function. If the task was canceled or exceeded the window scheduled for the task, the cause is often an undersized warehouse. Review the warehouse size and consider increasing it to fit within the schedule window or the one-hour limit.

Alternatively, consider increasing the timeout limit for the task by executing ALTER TASK … SET USER_TASK_TIMEOUT_MS = <num>.

A larger warehouse may not help if there are query parallelization issues. Consider looking at alternate ways to rewrite the SQL statement run by the task.