The execution of current disaster recovery tasks is subject to a limitation: except for migration replica tasks, a tenant's log stream can only allow one replica task to be executed at a time. This means some urgent tasks may need to wait until the ongoing task is completed before they can be executed. If you need to prioritize an urgent task, you can use the ALTER SYSTEM CANCEL REPLICA TASK command to manually cancel the running replica task.
Limitations
The current version only supports canceling two types of replica tasks: supplement replica and migration replica tasks.
Note
In the current version, for a replica migration task caused by unit migration, if the destination side has no units left, the system automatically cancels the corresponding replica migration task; manual cancellation is not required.
The sys tenant can cancel replica tasks for all tenants. User tenants can only cancel replica tasks for their own tenant.
Prerequisites
Before canceling a replica task, ensure the current user has the
ALTER SYSTEMprivilege; otherwise, theALTER SYSTEM CANCEL REPLICA TASKcommand cannot be executed.Before querying views, ensure the current user has the
SELECTprivilege on the following views; otherwise, the relevant information cannot be queried.DBA_OB_LS_REPLICA_TASKS/CDB_OB_LS_REPLICA_TASKSDBA_OB_LS_REPLICA_TASK_HISTORY/CDB_OB_LS_REPLICA_TASK_HISTORY
Procedure
Assume there is currently a tenant1 tenant, and an R replica of its log stream 1001 is undergoing a migration task. At this moment, a failure occurs in the current cluster, and it is urgently necessary to supplement an F replica on an available machine to ensure high availability. However, because the data volume of the migrating R replica is very large, the task is taking a long time to complete, preventing the timely execution of the urgent maintenance operation to supplement the F replica. In this case, maintenance personnel can refer to this document to manually cancel the disaster recovery task for the migrating R replica, thereby prioritizing the execution of some urgent maintenance operations.
Log in to the tenant corresponding to the cluster.
A connection example is as follows:
obclient -h172.30.xxx.xxx -P2883 -uroot@tenant1#obdemo -pxxxx -AFor more detailed instructions on connecting to a database, see Overview of database connections (MySQL-compatible mode) and Overview of database connections (Oracle-compatible mode).
View the currently running disaster recovery tasks.
System tenant
obclient [oceanbase]> SELECT * FROM oceanbase.CDB_OB_LS_REPLICA_TASKS\GFor detailed descriptions of the fields in the
CDB_OB_LS_REPLICA_TASKSview, see CDB_OB_LS_REPLICA_TASKS.User tenant
MySQL-compatible modeOracle-compatible modeExecute the following statement in MySQL-compatible mode:
obclient [oceanbase]> SELECT * FROM oceanbase.DBA_OB_LS_REPLICA_TASKS\GExecute the following statement in Oracle-compatible mode:
obclient [SYS]> SELECT * FROM SYS.DBA_OB_LS_REPLICA_TASKS\GThe following example shows the query result:
*************************** 1. row *************************** LS_ID: 1001 TASK_TYPE: MIGRATE REPLICA TASK_ID: Y13CE64586BD4-000610C5F3EDBBCB-0-0 TASK_STATUS: INPROGRESS PRIORITY: LOW TARGET_REPLICA_SVR_IP: 100.xx.xxx.002 TARGET_REPLICA_SVR_PORT: 5072 TARGET_PAXOS_REPLICA_NUMBER: 2 TARGET_REPLICA_TYPE: FULL SOURCE_REPLICA_SVR_IP: 100.xx.xxx.003 SOURCE_REPLICA_SVR_PORT: 5073 SOURCE_PAXOS_REPLICA_NUMBER: 2 SOURCE_REPLICA_TYPE: FULL DATA_SOURCE_SVR_IP: 100.xx.xxx.003 DATA_SOURCE_SVR_PORT: 5073 IS_MANUAL: FALSE TASK_EXEC_SVR_IP: 100.xx.xxx.002 TASK_EXEC_SVR_PORT: 5072 CREATE_TIME: 2024-02-07 15:23:04 START_TIME: 2024-02-07 15:23:04 MODIFY_TIME: 2024-02-07 15:23:04 COMMENT: migrate replica due to unit group not match CONFIG_VERSION: 1 row in setThe query result indicates that a disaster recovery task with
TASK_TYPEset toMIGRATE REPLICAis in progress, and itsTASK_IDis recorded.For more information about the columns in the
DBA_OB_LS_REPLICA_TASKSview, see DBA_OB_LS_REPLICA_TASKS.
Execute the command to cancel the replica task.
The statement is as follows:
ALTER SYSTEM CANCEL REPLICA TASK TASK_ID [=] 'task_id' [TENANT [=] 'tenant_name'];Usage instructions:
task_id: TheTASK_IDof the replica task to be canceled.tenant_name: Specifies the tenant to operate on. The system tenant can specify other tenants, while a user tenant can only specify itself. If the tenant to operate on is not explicitly specified, the default tenant name is the current tenant. This statement does not support usingall,all_user, orall_metato specify all tenants, user tenants, or all Meta tenants.This statement can only cancel one disaster recovery task per tenant at a time.
Example:
obclient> ALTER SYSTEM CANCEL REPLICA TASK TASK_ID = 'Y13CE64586BD4-000610C5F3EDBBCB-0-0';Check the cancellation result of the replica task.
System tenant
obclient [oceanbase]> SELECT * FROM oceanbase.CDB_OB_LS_REPLICA_TASK_HISTORY WHERE TASK_ID = 'Y13CE64586BD4-000610C5F3EDBBCB-0-0'\GFor more information about the columns in the
CDB_OB_LS_REPLICA_TASK_HISTORYview, see CDB_OB_LS_REPLICA_TASK_HISTORY.User tenant
MySQL-compatible modeOracle-compatible modeIn MySQL-compatible mode, execute the following statement:
obclient [oceanbase]> SELECT * FROM oceanbase.DBA_OB_LS_REPLICA_TASK_HISTORY WHERE TASK_ID = 'Y13CE64586BD4-000610C5F3EDBBCB-0-0'\GIn Oracle-compatible mode, execute the following statement:
obclient [SYS]> SELECT * FROM SYS.DBA_OB_LS_REPLICA_TASK_HISTORY WHERE TASK_ID = 'Y13CE64586BD4-000610C5F3EDBBCB-0-0'\GThe following example shows the query result:
*************************** 1. row *************************** LS_ID: 1001 TASK_TYPE: MIGRATE REPLICA TASK_ID: Y13CE64586BD4-000610C5F3EDBBCB-0-0 TASK_STATUS: CANCELED PRIORITY: LOW TARGET_REPLICA_SVR_IP: 100.xx.xxx.002 TARGET_REPLICA_SVR_PORT: 5072 TARGET_PAXOS_REPLICA_NUMBER: 2 TARGET_REPLICA_TYPE: FULL SOURCE_REPLICA_SVR_IP: 100.xx.xxx.003 SOURCE_REPLICA_SVR_PORT: 5073 SOURCE_PAXOS_REPLICA_NUMBER: 2 SOURCE_REPLICA_TYPE: FULL DATA_SOURCE_SVR_IP: 100.xx.xxx.003 DATA_SOURCE_SVR_PORT: 5073 IS_MANUAL: FALSE TASK_EXEC_SVR_IP: 100.xx.xxx.002 TASK_EXEC_SVR_PORT: 5072 CREATE_TIME: 2024-02-07 15:54:35 START_TIME: 2024-02-07 15:54:31 MODIFY_TIME: 2024-02-07 15:54:35 FINISH_TIME: 2024-02-07 15:54:34 EXECUTE_RESULT: ret:-4072, OB_CANCELED; elapsed:4109659; comment:[storage] receive task reply from storage rpc; COMMENT: migrate replica due to unit not match CONFIG_VERSION: 1 row in setIn the query result, if
TASK_STATUSisCANCELED, the task has been canceled.For more information about the columns in the
DBA_OB_LS_REPLICA_TASK_HISTORYview, see DBA_OB_LS_REPLICA_TASK_HISTORY.
