

# ALTER DBCLUSTERGROUP CANCEL JOB

Cancels a data movement job in a database cluster group for Aurora before its cutover.

## Description
<a name="databaseclustergroups-sql-cancel-job-description"></a>

A canceled job leaves the collocation on its source member cluster, and the collocation's data mappings still name the source. The job drops exactly the objects that it created on the target, in reverse dependency order, and leaves the objects on the source untouched. A job that fails before its cutover cleans up the target in the same way.

## Syntax
<a name="databaseclustergroups-sql-cancel-job-syntax"></a>

The syntax is as follows.

```sql
ALTER DBCLUSTERGROUP CANCEL JOB '{{job_id}}';
```

## Parameters and options
<a name="databaseclustergroups-sql-cancel-job-parameters"></a>

The statement takes the following parameter.

{{job\_id}}  
The job ID from the result of `ALTER DBCLUSTERGROUP MOVE COLLOCATION` or from `move_info`, as a string literal in single quotes.

## Where it runs and required privileges
<a name="databaseclustergroups-sql-cancel-job-privileges"></a>

Run the statement at the routing endpoint, outside a transaction, in a session that isn't pinned. Inside a transaction, the statement returns error 1179. The router user needs `dbclustergroup_move_admin` or `dbclustergroup_super_admin`. For the privileges for database cluster groups for Aurora, see [Privileges](databaseclustergroups-sql-reference.md#databaseclustergroups-sql-privileges).

## Usage notes
<a name="databaseclustergroups-sql-cancel-job-usage"></a>

Keep the following in mind when you use the statement.
+ Confirm that the job hasn't begun its cutover, and then cancel it. To confirm the job's terminal state, read its row in [Reading move status](databaseclustergroups-sql-move-info.md).
+ The routing layer refuses a cancel while the cutover is in progress. After the cutover, the job has nothing to cancel.

A canceled job reads `Cancelled` in the `status` column of `move_info`. Cleanup runs after a job is canceled, which you can see in the `cleanup_status` column of `move_info`. You can change the data mappings of the collocation or run another data movement job on the collocation after the cleanup completes.

## Examples
<a name="databaseclustergroups-sql-cancel-job-examples"></a>

The following example cancels a running job.

```sql
ALTER DBCLUSTERGROUP CANCEL JOB '4a6f1c2e-7d3b-4c1a-9e2f-5b8d0c6a1f30';
```

## Errors
<a name="databaseclustergroups-sql-cancel-job-errors"></a>

The statement can return the following errors. For all data movement errors, see [Data movement errors](databaseclustergroups-errors-movement.md).


| Code (SQLSTATE) | Message | Meaning | 
| --- | --- | --- | 
| 1227 (42000) | Access denied; you need the 'DBCLUSTERGROUP\_MOVE\_ADMIN' privilege for this operation | Your router user lacks the dbclustergroup\_move\_admin privilege. | 
| 1179 (25000) | You are not allowed to execute this command in a transaction | The statement ran inside a transaction. Run it outside a transaction. | 
| 1221 (HY000) | Cannot cancel a job that has reached the cutover phase | The job is in CutoverInit or CutoverFlip, or past it. You can't cancel it. | 
| 1221 (HY000) | Cannot cancel a job in the {{state}} state | The job has ended. {{state}} is one of COMPLETED, ERROR or CANCELLED. | 
| 1525 (HY000) | Incorrect job ID value: '{{value}}' | The job ID isn't a valid ID. | 
| 1305 (42000) | MOVE JOB '{{job\_id}}' does not exist | This job ID does not exist in this database cluster group for Aurora. | 

## Related statements
<a name="databaseclustergroups-sql-cancel-job-related"></a>

For more information, see the following:
+ [ALTER DBCLUSTERGROUP MOVE COLLOCATION](databaseclustergroups-sql-move-collocation.md)
+ [ALTER DBCLUSTERGROUP CUTOVER JOB](databaseclustergroups-sql-switch-job.md)
+ [Reading move status](databaseclustergroups-sql-move-info.md)