Skip to main content
The CANCEL JOB lets you stop long-running jobs, which include:

Known limitations

  • To avoid transaction states that cannot properly , the following statements cannot be cancelled with :
    • DROP statements (e.g., ).
    • ALTER... RENAME statements (e.g., ).
    • statements.
    • statements, except for those that drop values.
  • When an Enterprise is canceled, partially restored data is properly cleaned up. This can have a minor, temporary impact on cluster performance.

Required privileges

To cancel a job, the user must be a member of the admin role or must have the set. Non-admin users cannot cancel admin users’ jobs. For changefeeds, users with the privilege on a set of tables can cancel changefeed jobs running on those tables.

Synopsis

cancel_job syntax diagram

Cancel all jobs by type

cancel_all_jobs syntax diagram SQL syntax diagram

Parameters

ParameterDescription
job\_idThe ID of the job you want to cancel, which can be found with .
select\_stmtA that returns job\_id(s) to cancel.
for\_schedules\_clauseThe schedule you want to cancel jobs for. You can cancel jobs for a specific schedule (FOR SCHEDULE id) or cancel jobs for multiple schedules by nesting a in the statement (FOR SCHEDULES ). See the examples below.
BACKUP, CHANGEFEED, RESTORE, IMPORTThe job type to cancel.

Examples

Cancel a single job

Cancel multiple jobs

To cancel multiple jobs, nest a that retrieves job_id(s) inside the CANCEL JOBS statement:
All jobs created by maxroach will be cancelled.

Cancel by job type

To cancel all jobs by the type of job, use the CANCEL ALL {job} JOBS statement. You can cancel all BACKUP, RESTORE, CHANGEFEED, IMPORT jobs using this statement, for example:

Cancel automatic table statistics jobs

Canceling an automatic table statistics job is not useful since the system will automatically restart the job immediately. To permanently disable automatic table statistics jobs, disable the sql.stats.automatic_collection.enabled :

Cancel jobs for a schedule

To cancel jobs for a specific , use the schedule’s id:
You can also CANCEL multiple schedules by nesting a that retrieves id(s) inside the CANCEL JOBS statement:

See also