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

Known limitations

  • To avoid transaction states that cannot properly roll back, the following statements cannot be cancelled with CANCEL JOB:
  • When an Enterprise RESTORE 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 CONTROLJOB role option set. Non-admin users cannot cancel admin users’ jobs. For changefeeds, users with the CHANGEFEED 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

Examples

Cancel a single job

Cancel multiple jobs

To cancel multiple jobs, nest a SELECT clause 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 cluster setting:

Cancel jobs for a schedule

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

See also