Skip to content

Latest commit

 

History

History
107 lines (79 loc) · 3.8 KB

cancel-job.md

File metadata and controls

107 lines (79 loc) · 3.8 KB
title summary toc
CANCEL JOB
The CANCEL JOB statement stops long-running jobs such as imports, backups, and schema changes.such as imports, backups, and schema changes.
true

The CANCEL JOB statement lets you stop long-running jobs, which include:

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

To cancel a job, the user must be a member of the admin role or must have the CONTROLJOB parameter set. Non-admin users cannot cancel admin users' jobs.

Synopsis

{% include {{ page.version.version }}/sql/generated/diagrams/cancel_job.html %}

Parameters

Parameter Description
job_id The ID of the job you want to cancel, which can be found with SHOW JOBS.
select_stmt A selection query that returns job_id(s) to cancel.
for_schedules_clause The 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 SELECT clause in the statement (FOR SCHEDULES <select_clause>). See the examples below.

Examples

Cancel a single job

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

Cancel multiple jobs

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

{% include copy-clipboard.html %}

> CANCEL JOBS (SELECT job_id FROM [SHOW JOBS]
      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:

{% include copy-clipboard.html %}

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

Cancel jobs for a schedule

To cancel jobs for a specific backup schedule, use the schedule's id:

{% include copy-clipboard.html %}

> CANCEL JOBS FOR SCHEDULE 590204387299262465;
CANCEL JOBS FOR SCHEDULES 1

You can also CANCEL multiple schedules by nesting a SELECT clause that retrieves id(s) inside the CANCEL JOBS statement:

{% include copy-clipboard.html %}

> CANCEL JOBS FOR SCHEDULES SELECT id FROM [SHOW SCHEDULES] WHERE label = 'test_schedule';
CANCEL JOBS FOR SCHEDULES 2

See also