CANCEL JOB

The CANCEL JOB statement lets you stop long-running jobs, which include IMPORT jobs, enterprise BACKUP and RESTORE jobs, schema changes, user-created table statistics jobs, automatic table statistics jobs, and changefeeds.

Limitations

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

Only members of the admin role can cancel a job. By default, the root user belongs to the admin role.

Synopsis

CANCELJOBjob_idJOBSselect_stmt

Parameters

ParameterDescription
job_idThe ID of the job you want to cancel, which can be found with SHOW JOBS.
select_stmtA selection query that returns job_id(s) to cancel.

Examples

Cancel a single job

  1. > SHOW JOBS;
  1. +----------------+---------+-------------------------------------------+...
  2. | id | type | description |...
  3. +----------------+---------+-------------------------------------------+...
  4. | 27536791415282 | RESTORE | RESTORE db.* FROM 'azure://backup/db/tbl' |...
  5. +----------------+---------+-------------------------------------------+...
  1. > CANCEL JOB 27536791415282;

Cancel multiple jobs

To cancel multiple jobs, nest a SELECT clause that retrieves job_id(s) inside the CANCEL JOBS statement:

  1. > CANCEL JOBS (SELECT job_id FROM [SHOW JOBS]
  2. WHERE user_name = 'maxroach');

All jobs created by maxroach will be cancelled.

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:

  1. > SET CLUSTER SETTING sql.stats.automatic_collection.enabled = false;

See also

Was this page helpful?
YesNo