- Categories:
System functions (System Control)
SYSTEM$CANCEL_ TASK_ GRAPH¶
Cancels one or all runs of a task graph, stopping work that is queued or scheduled under the targeted run or runs and marking any task that is already executing so that it completes with a CANCELLED state.
In this function, a task graph is either a classic task tree rooted at a root task or a task graph object. For more information about tasks, see Introduction to tasks.
Syntax¶
Arguments¶
You must pass every argument by name (for example, GRAPH_NAME => 'my_graph'). Positional calls are rejected. Exactly one of ROOT_NAME or GRAPH_NAME is required.
ROOT_NAME => 'root_task_name'The fully qualified name of the root task of a classic task tree.
Required unless you specify
GRAPH_NAME. This argument is mutually exclusive withGRAPH_NAME.If the name you pass belongs to a task that isn’t a root task, the call fails with an error that identifies the correct task name or task graph to use.
GRAPH_NAME => 'task_graph_name'The fully qualified name of a task graph object.
Required unless you specify
ROOT_NAME. This argument is mutually exclusive withROOT_NAME.CANCEL_FINALIZER => TRUE | FALSESpecifies whether the graph’s finalizer task is also cancelled.
By default (
FALSE), the finalizer task is spared and still runs to completion after the rest of the graph is cancelled. Set this argument toTRUEto also cancel the finalizer task.Default:
FALSEGRAPH_RUN_UUID => 'uuid'The ID of one specific graph run to cancel. This is the
GRAPH_RUN_GROUP_IDvalue for the run, which you can retrieve from the CURRENT_TASK_GRAPHS or COMPLETE_TASK_GRAPHS function.If you omit this argument, the function cancels every currently incomplete run of the named task graph. This is the default behavior.
This argument currently supports only one run ID per call.
Returns¶
Returns a string that describes the outcome of the call. The exact message depends on how many matching runs the function finds and their state. For example, the function returns a message that reports one of the following outcomes:
-
The number of graph runs that were cancelled, noting whether the finalizer task was spared (for example,
2 graph run(s) cancelled (except finalizer).) or included (for example,2 graph run(s) cancelled.). -
No matching run was found to cancel, because the run already finished or nothing is currently running. The message asks you to confirm the run that you intended to cancel and try again.
-
The targeted run or runs were already being cancelled by an earlier call. The message reports how many runs are already cancelling from an earlier request.
-
The targeted run or runs finished in the brief window before the cancellation took effect. The message explains that the runs might have completed while the cancellation was in progress and suggests that you check the run status and retry if needed.
Access control requirements¶
To call this function, you must use a role that has one of the following privileges on the task or task graph that you specify:
- OPERATE
- OWNERSHIP
Usage notes¶
-
ROOT_NAMEandGRAPH_NAMEare mutually exclusive, and exactly one of them is required per call. Supplying both, or neither, is an error. -
Only named-argument syntax is supported. Positional calls are rejected.
-
Passing any argument as
NULLis rejected. To omit an optional argument, leave it out of the call. For example, you can’t passGRAPH_RUN_UUID => NULLto mean “omit it.” -
If you omit
GRAPH_RUN_UUID, the function cancels all currently incomplete runs of the task graph, not just one. To cancel a single run, pass that run’sGRAPH_RUN_GROUP_IDvalue inGRAPH_RUN_UUID. You can retrieve this value from the CURRENT_TASK_GRAPHS or COMPLETE_TASK_GRAPHS function. -
The finalizer task, if the graph has one, isn’t cancelled unless you explicitly set
CANCEL_FINALIZER => TRUE. -
Cancellation isn’t instantaneous for in-flight work. A task that is already running finishes its current execution and is then marked
CANCELLED, rather than being interrupted mid-execution.
Examples¶
Cancel every run of a classic task tree by specifying its root task name:
Cancel every run of a task graph object by specifying its name:
Cancel one specific run of a task graph by specifying the run ID:
Cancel every run of a task graph, including its finalizer task: