After manually initiating a partition transfer, you can cancel the task based on your business needs.
Limitations
- You cannot cancel a partition transfer task in the
DOINGstate, but you can cancel tasks in other states.
Cancel a partition transfer task in the sys tenant
Log in to the
systenant of the cluster as therootuser.Note that you must specify the corresponding options in the following sample code based on your actual database configurations.
obclient -h10.xx.xx.xx -P2883 -uroot@sys#obdemo -p***** -AQuery the
CDB_OB_TRANSFER_PARTITION_TASKSview for the status of the current task.obclient [oceanbase]> SELECT TENANT_ID, TABLE_ID, OBJECT_ID, STATUS FROM oceanbase.CDB_OB_TRANSFER_PARTITION_TASKS WHERE TENANT_ID = 1002;The query result is as follows:
+-----------+----------+-----------+---------+ | TENANT_ID | TABLE_ID | OBJECT_ID | STATUS | +-----------+----------+-----------+---------+ | 1002 | 500006 | 500008 | WAITING | +-----------+----------+-----------+---------+ 1 row in setOnly tasks with a
STATUSother thanDOING(such asWAITINGorINIT) can be canceled in the query result.If the
STATUSof the task you want to cancel isDOING, you can disable the transfer feature by setting the tenant-level parameterenable_transfertofalse. After disabling the transfer feature, all partition transfer tasks in theDOINGstate will roll back to theWAITINGstate, and then you can cancel the partition transfer task.For more information about the
enable_transferparameter, see enable_transfer.Perform the appropriate operation based on the query result:
Cancel a partition transfer task for a specified partition in a specified tenant
ALTER SYSTEM CANCEL TRANSFER PARTITION TABLE_ID [=] table_id OBJECT_ID [=] object_id TENANT = 'tenant_name';where
table_id: The ID of the table containing the partition to be canceled.object_id: The ID of the partition to be canceled.tenant_name: The name of the tenant containing the partition to be canceled.
Here is an example:
obclient [oceanbase]> ALTER SYSTEM CANCEL TRANSFER PARTITION TABLE_ID = 500006, OBJECT_ID = 500008 TENANT = 'mysql_tenant';Cancel all partition transfer tasks for a specified tenant.
ALTER SYSTEM CANCEL TRANSFER PARTITION ALL TENANT = 'tenant_name';Here is an example:
obclient [oceanbase]> ALTER SYSTEM CANCEL TRANSFER PARTITION ALL TENANT = 'mysql_tenant';
Cancel a partition transfer task in a user tenant
Connect to the database as the tenant administrator of the user tenant.
Note that you must specify the corresponding options in the following sample code based on your actual database configurations.
obclient -h10.xx.xx.xx -P2883 -uroot@mysql_tenant#obdemo -p***** -AQuery the
DBA_OB_TRANSFER_PARTITION_TASKSview for the status of the current task.The query statement is as follows:
obclient [oceanbase]> SELECT TABLE_ID, OBJECT_ID, STATUS FROM oceanbase.DBA_OB_TRANSFER_PARTITION_TASKS;A sample query result is shown below:
+----------+-----------++--------+ | TABLE_ID | OBJECT_ID | STATUS | +----------+-----------+--------+ | 500046 | 500052 | INIT | +----------+-----------+--------+ 1 row in setOnly tasks with a
STATUSother thanDOING(such asWAITINGorINIT) can be canceled in the query result.If the
STATUSof the task you want to cancel isDOING, you can disable the transfer feature by setting the tenant-level parameterenable_transfertofalse. After the transfer feature is disabled, all partition transfer tasks in theDOINGstate will roll back to theWAITINGstate, and then you can cancel the partition transfer task.For more information about the
enable_transferparameter, see enable_transfer.Perform the appropriate operation based on the query result:
Cancel the partition transfer task for a specified partition in the current tenant.
ALTER SYSTEM CANCEL TRANSFER PARTITION TABLE_ID [=] table_id OBJECT_ID [=] object_id;where
table_id: The ID of the table containing the partition to be canceled.object_id: The ID of the partition to be canceled.
Here is an example:
obclient [oceanbase]> ALTER SYSTEM CANCEL TRANSFER PARTITION TABLE_ID = 500046, OBJECT_ID = 500052;Cancel all partition transfer tasks in the current tenant.
obclient> ALTER SYSTEM CANCEL TRANSFER PARTITION ALL;