View a markdown version of this page

ALTER DBCLUSTERGROUP CUTOVER JOB - Amazon Aurora

ALTER DBCLUSTERGROUP CUTOVER JOB

Starts the cutover, the final step of a move, for a data movement job in a database cluster group for Aurora. Use it to cut over a job that you started with MANUAL_CUTOVER = 1, or to cut over an automatic job earlier.

Description

At the cutover, the job fences the moving objects on the source and ends every transaction that is open on them. Each such transaction rolls back, and the session receives an error or loses its connection, so retry it. The last changes then apply, and the job updates the collocation's data mappings to name the target member cluster. The job then drops the source copy. Use this statement to choose when the cutover happens. A job accepts it while the job is in the CDC Replication phase and replication lag is at or below the bound that you set. For the error codes, see Moving data between member clusters.

A data movement job that you started with MANUAL_CUTOVER = 1 will not cut over until you run this command. You can also run this statement on a job that cuts over automatically if you want to cut over with replication lag greater than 1 second.

Syntax

The syntax is as follows.

ALTER DBCLUSTERGROUP CUTOVER JOB 'job_id' [MAX_REPLICATION_LAG_SECONDS = seconds];

Parameters and options

The statement takes the following parameters.

job_id

The job ID from the move result or from move_info, as a string literal in single quotes.

MAX_REPLICATION_LAG_SECONDS = seconds

Optional. The cutover starts only when replication lag is below this bound. The range is 1 to 300 seconds, and the default is 10 seconds.

Where it runs and required privileges

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.

Usage notes

Keep the following in mind when you use the statement.

  • Before you start the cutover, read the job's replication lag in Reading move status. The cutover starts only while replication lag is below the bound, so the job refuses a statement that you send while lag is higher. Read the lag again, and send the statement when it is lower. For the job events, see Reading move status.

  • The job accepts the statement only in the CDC Replication phase (Cdc in the phase column of move_info), after the Seeding phase completes.

  • During the cutover, the job refuses reads and writes to the moving objects and doesn't hold them, so your application must retry the query. For the error codes, see Moving data between member clusters.

Important

A large MAX_REPLICATION_LAG_SECONDS value can lengthen the time that reads and writes to the moving objects are rejected.

Examples

The following example starts the cutover of a job when replication lag is below 30 seconds.

ALTER DBCLUSTERGROUP CUTOVER JOB '4a6f1c2e-7d3b-4c1a-9e2f-5b8d0c6a1f30' MAX_REPLICATION_LAG_SECONDS = 30;

The following example cuts over a job that you started without MANUAL_CUTOVER = 1, when replication lag is below 5 seconds:

ALTER DBCLUSTERGROUP CUTOVER JOB '4a6f1c2e-7d3b-4c1a-9e2f-5b8d0c6a1f30' MAX_REPLICATION_LAG_SECONDS = 5;

Errors

The statement can return the following errors. For all data movement errors, see Data movement errors.

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 cut over a job in the phase phase. The job must be in the CDC phase to perform cutover The job isn't in the CDC Replication phase yet. phase is in capitals.
1221 (HY000) Replication lag (n seconds) is not below the maximum replication lag threshold (n seconds) Replication lag is at or above the bound. Read the lag in move_info, and run the statement again when it is lower.
1221 (HY000) Replication lag has not been reported for this job yet; retry once replication progress is available The job hasn't reported any lag yet.
1525 (HY000) Incorrect MAX_REPLICATION_LAG_SECONDS value: 'value'; it must be between 1 and 300 seconds The bound is outside 1 to 300.
1221 (HY000) Cannot cut over a job in the state state The job has ended. state is in capitals, for example COMPLETED.
1221 (HY000) Cannot cut over a job with a cancel in progress Someone canceled the job.
1525 (HY000) Incorrect job ID value: 'value' The job ID isn't a valid ID.
1305 (42000) MOVE JOB 'job_id' does not exist No job has this ID.

For more information, see the following: