One log stream of a tenant supports only one replica task at a time. You can perform a new task only after the ongoing task is completed. If you want to perform an emergency task with priority, you can execute the ALTER SYSTEM CANCEL REPLICA TASK statement to cancel the ongoing replica task and then initiate the emergency task.
Limitations
You can cancel only a replica adding or migration task.
You can cancel replica tasks of all tenants in the
systenant but cancel only replica tasks of the current tenant in a user tenant.
Prerequisites
You have the
ALTER SYSTEMprivilege.You have the
SELECTprivilege on the following views:DBA_OB_LS_REPLICA_TASKSandCDB_OB_LS_REPLICA_TASKSDBA_OB_LS_REPLICA_TASK_HISTORYandCDB_OB_LS_REPLICA_TASK_HISTORY
Procedure
Assume that a task to migrate a read-only replica of log stream 1001 of a tenant named tenant1 is in progress and a full-featured replica needs to be added to an available OBServer node to ensure high availability upon an exception of the cluster. However, the read-only replica involves a large amount of data, and the replica migration task is unlikely to complete anytime soon. Consequently, the emergency task to add a full-featured replica cannot be performed immediately. In this case, you can cancel the ongoing replica migration task and perform the emergency task with priority.
Log in to the target tenant.
Here is an example:
obclient -h172.30.xxx.xxx -P2883 -uroot@tenant1#obdemo -pxxxx -AFor more information about how to connect to a database, see Overview (MySQL mode) or Overview (Oracle mode).
Query the ongoing replica task.
systenantobclient [oceanbase]> SELECT * FROM oceanbase.CDB_OB_LS_REPLICA_TASKS;For more information about the fields in the
CDB_OB_LS_REPLICA_TASKSview, see CDB_OB_LS_REPLICA_TASKS.User tenant
MySQL modeOracle modeExecute the following statement in MySQL mode:
obclient [oceanbase]> SELECT * FROM oceanbase.DBA_OB_LS_REPLICA_TASKS;Execute the following statement in Oracle mode:
obclient [SYS]> SELECT * FROM SYS.DBA_OB_LS_REPLICA_TASKS;A sample query result is as follows:
+-------+-----------------+------------------------------------+-------------+----------+-----------------------+-------------------------+-----------------------------+---------------------+-----------------------+-------------------------+-----------------------------+---------------------+--------------------+----------------------+-----------+------------------+--------------------+---------------------+---------------------+---------------------+---------------------------------------------+ | LS_ID | TASK_TYPE | TASK_ID | TASK_STATUS | PRIORITY | TARGET_REPLICA_SVR_IP | TARGET_REPLICA_SVR_PORT | TARGET_PAXOS_REPLICA_NUMBER | TARGET_REPLICA_TYPE | SOURCE_REPLICA_SVR_IP | SOURCE_REPLICA_SVR_PORT | SOURCE_PAXOS_REPLICA_NUMBER | SOURCE_REPLICA_TYPE | DATA_SOURCE_SVR_IP | DATA_SOURCE_SVR_PORT | IS_MANUAL | TASK_EXEC_SVR_IP | TASK_EXEC_SVR_PORT | CREATE_TIME | START_TIME | MODIFY_TIME | COMMENT | +-------+-----------------+------------------------------------+-------------+----------+-----------------------+-------------------------+-----------------------------+---------------------+-----------------------+-------------------------+-----------------------------+---------------------+--------------------+----------------------+-----------+------------------+--------------------+---------------------+---------------------+---------------------+---------------------------------------------+ | 1001 | MIGRATE REPLICA | Y13CE64586BD4-000610C5F3EDBBCB-0-0 | INPROGRESS | LOW | 100.xx.xxx.002 | 5072 | 2 | FULL | 100.xx.xxx.003 | 5073 | 2 | FULL | 100.xx.xxx.003 | 5073 | FALSE | 100.xx.xxx.002 | 5072 | 2024-02-07 15:23:04 | 2024-02-07 15:23:04 | 2024-02-07 15:23:04 | migrate replica due to unit group not match | +-------+-----------------+------------------------------------+-------------+----------+-----------------------+----------------------- +-----------------------------+---------------------+-----------------------+-------------------------+-----------------------------+---------------------+--------------------+----------------------+-----------+------------------+--------------------+---------------------+---------------------+---------------------+---------------------------------------------+ 1 row in setThe query result shows that the replica task with the task type of
MIGRATE REPLICAis in progress. Record the task ID of the task.For more information about the fields in the
DBA_OB_LS_REPLICA_TASKSview, see DBA_OB_LS_REPLICA_TASKS.
Execute the
ALTER SYSTEM CANCEL REPLICA TASKstatement to cancel the ongoing replica task.The syntax is as follows:
ALTER SYSTEM CANCEL REPLICA TASK TASK_ID [=] 'task_id' [TENANT [=] 'tenant_name'];The parameters in the syntax are described as follows:
task_id: the task ID of the replica task to be canceled.tenant_name: the name of the target tenant. You can specify another tenant in thesystenant and specify only the current tenant in a user tenant. If this parameter is not specified, the name of the current tenant is used. You cannot use theall,all_user, orall_metaoption in this statement to specify all tenants, all user tenants, or all meta tenants.This statement cancels only one replica task of the tenant at a time.
Here is an example:
obclient> ALTER SYSTEM CANCEL REPLICA TASK TASK_ID = 'Y13CE64586BD4-000610C5F3EDBBCB-0-0';Check whether the replica task is canceled.
systenantobclient [oceanbase]> SELECT * FROM oceanbase.CDB_OB_LS_REPLICA_TASK_HISTORY WHERE TASK_ID = 'Y13CE64586BD4-000610C5F3EDBBCB-0-0';For more information about the fields in the
CDB_OB_LS_REPLICA_TASK_HISTORYview, see CDB_OB_LS_REPLICA_TASK_HISTORY.User tenant
MySQL modeOracle modeExecute the following statement in MySQL mode:
obclient [oceanbase]> SELECT * FROM oceanbase.DBA_OB_LS_REPLICA_TASK_HISTORY WHERE TASK_ID = 'Y13CE64586BD4-000610C5F3EDBBCB-0-0';Execute the following statement in Oracle mode:
obclient [SYS]> SELECT * FROM SYS.DBA_OB_LS_REPLICA_TASK_HISTORY WHERE TASK_ID = 'Y13CE64586BD4-000610C5F3EDBBCB-0-0';A sample query result is as follows:
+-------+-----------------+------------------------------------+-------------+----------+-----------------------+-------------------------+-----------------------------+---------------------+-----------------------+-------------------------+-----------------------------+---------------------+--------------------+----------------------+-----------+------------------+--------------------+---------------------+---------------------+---------------------+---------------------+-------------------------------------------------------------------------------------------------+---------------------------------------------+ | LS_ID | TASK_TYPE | TASK_ID | TASK_STATUS | PRIORITY | TARGET_REPLICA_SVR_IP | TARGET_REPLICA_SVR_PORT | TARGET_PAXOS_REPLICA_NUMBER | TARGET_REPLICA_TYPE | SOURCE_REPLICA_SVR_IP | SOURCE_REPLICA_SVR_PORT | SOURCE_PAXOS_REPLICA_NUMBER | SOURCE_REPLICA_TYPE | DATA_SOURCE_SVR_IP | DATA_SOURCE_SVR_PORT | IS_MANUAL | TASK_EXEC_SVR_IP | TASK_EXEC_SVR_PORT | CREATE_TIME | START_TIME | MODIFY_TIME | FINISH_TIME | EXECUTE_RESULT | COMMENT | +-------+-----------------+------------------------------------+-------------+----------+-----------------------+-------------------------+-----------------------------+---------------------+-----------------------+-------------------------+-----------------------------+---------------------+--------------------+----------------------+-----------+------------------+--------------------+---------------------+---------------------+---------------------+---------------------+-------------------------------------------------------------------------------------------------+---------------------------------------------+ | 1001 | MIGRATE REPLICA | Y13CE64586BD4-000610C5F3EDBBCB-0-0 | CANCELED | LOW | 100.xx.xxx.002 | 5072 | 2 | FULL | 100.xx.xxx.003 | 5073 | 2 | FULL | 100.xx.xxx.003 | 5073 | FALSE | 100.xx.xxx.002 | 5072 | 2024-02-07 15:54:35 | 2024-02-07 15:54:31 | 2024-02-07 15:54:35 | 2024-02-07 15:54:34 | ret:-4072, OB_CANCELED; elapsed:4109659; comment:[storage] receive task reply from storage rpc; | migrate replica due to unit group not match | +-------+-----------------+------------------------------------+-------------+----------+-----------------------+-------------------------+-----------------------------+---------------------+-----------------------+-------------------------+-----------------------------+---------------------+--------------------+----------------------+-----------+------------------+--------------------+---------------------+---------------------+---------------------+---------------------+-------------------------------------------------------------------------------------------------+---------------------------------------------+ 1 row in setThe query result shows that the status of the task is
CANCELED.For more information about the fields in the
DBA_OB_LS_REPLICA_TASK_HISTORYview, see DBA_OB_LS_REPLICA_TASK_HISTORY.