Skip to main content
Version: Candidate-4.1

ALTER TASK

Modifies an asynchronous ETL task submitted using SUBMIT TASK. This feature has been supported from v4.1 onwards.

You can use this statement to:

  • Suspend a running task
  • Resume a suspended task
  • Update task properties

Syntax​

ALTER TASK [IF EXISTS] <task_name> { RESUME | SUSPEND | SET ('key' = 'value'[, ...]) }

Parameters​

ParameterRequiredDescription
IF EXISTSNoIf this parameter is specified, StarRocks will not throw an exception when modifying a task that does not exist. If this parameter is not specified, the system will throw an exception when modifying a task that does not exist.
task_nameYesThe name of the task to modify.
RESUMENoResumes a suspended task. The task will be scheduled according to its original schedule (for periodic tasks) or be available for manual execution (for manual tasks).
SUSPENDNoSuspends a running task. For periodic tasks, this stops the task scheduler and kills any running task runs.
SETNoUpdates the properties of the task. The properties will be merged with existing properties and applied to subsequent task executions.

Usage notes​

  • You can check the information of asynchronous tasks by querying the metadata views tasks and task_runs in Information Schema.

    SELECT * FROM INFORMATION_SCHEMA.tasks;
    SELECT * FROM information_schema.tasks WHERE task_name = '<task_name>';
    SELECT * FROM information_schema.task_runs;
    SELECT * FROM information_schema.task_runs WHERE task_name = '<task_name>';
  • The SUSPEND action stops the task scheduler for periodic tasks and kills any currently running task runs. The task state will be changed to PAUSE.

  • The RESUME action restarts the task scheduler for periodic tasks. The task state will be changed to ACTIVE.

  • The SET action updates task properties that will be applied to subsequent task executions. You can use session. prefix with session variables to change the task running connect context configurations.

Examples​

Example 1: Suspend a task named etl_task:

ALTER TASK etl_task SUSPEND;

Example 2: Resume a suspended task named etl_task:

ALTER TASK etl_task RESUME;

Example 3: Update the query timeout for a task named etl_task:

ALTER TASK etl_task SET ('session.query_timeout' = '5000');

Example 4: Update multiple properties for a task:

ALTER TASK etl_task SET (
'session.query_timeout' = '5000',
'session.enable_profile' = 'true'
);

Example 5: Suspend a task only if it exists (avoid error if task does not exist):

ALTER TASK IF EXISTS etl_task SUSPEND;
Rocky the happy otterStarRocks Assistant

AI generated answers are based on docs and other sources. Please test answers in non-production environments.