When a tenant has a running balance job and other urgent changes need to be performed, you can stop the current balance job to prevent its execution from affecting the urgent changes. After the urgent changes are completed, you can resume the job to continue its execution.
Limitations
- The status of the balance job must not be
CANCELINGwhen stopping or resuming it.
Stop a running balance job
Stop a running balance job of a user tenant in the sys tenant
Log in to the
systenant of the cluster as therootuser.Note that you must specify the corresponding parameters in the following sample code based on your actual database configuration.
obclient -h10.xx.xx.xx -P2883 -uroot@sys#obdemo -p***** -AQuery the tenant information.
obclient(root@sys)[oceanbase]> SELECT TENANT_ID, TENANT_NAME, TENANT_ROLE FROM oceanbase.DBA_OB_TENANTS WHERE tenant_name = 'mq_t1';A sample query result is as follows:
+-------------+-----------+-------------+ | TENANT_NAME | TENANT_ID | TENANT_ROLE | +-------------+-----------+-------------+ | mq_t1 | 1002 | PRIMARY | +-------------+-----------+-------------+ 1 row in setQuery the
CDB_OB_BALANCE_JOBSview for the status and information about the current job.obclient(root@sys)[oceanbase]> SELECT TENANT_ID, JOB_ID, JOB_TYPE, STATUS FROM oceanbase.CDB_OB_BALANCE_JOBS WHERE TENANT_ID = 1002;A sample query result is as follows:
+-----------+--------+--------------------+--------+ | TENANT_ID | JOB_ID | JOB_TYPE | STATUS | +-----------+--------+--------------------+--------+ | 1002 | 62944 | TRANSFER_PARTITION | DOING | +-----------+--------+--------------------+--------+ 1 row in setIn the query result, if the status of the current job is
DOINGinstead ofCANCELING, you can stop the job.Execute the following statement to stop the balance job.
ALTER SYSTEM SUSPEND BALANCE JOB TENANT = 'tenant_name';A sample execution is as follows:
obclient(root@sys)[oceanbase]> ALTER SYSTEM SUSPEND BALANCE JOB TENANT ='mq_t1';After the job is stopped, query the
CDB_OB_BALANCE_JOBSview again. The status of the job should have changed toSUSPEND.obclient(root@sys)[oceanbase]> SELECT TENANT_ID, JOB_ID, JOB_TYPE, STATUS FROM oceanbase.CDB_OB_BALANCE_JOBS WHERE TENANT_ID = 1002;The query result is as follows:
+-----------+--------+--------------------+---------+ | TENANT_ID | JOB_ID | JOB_TYPE | STATUS | +-----------+--------+--------------------+---------+ | 1002 | 62944 | TRANSFER_PARTITION | SUSPEND | +-----------+--------+--------------------+---------+ 1 row in set
Stop a running balance job in the current tenant as a user tenant
The tenant administrator of the user tenant connects to the database.
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_BALANCE_JOBSview for information about the currently running tasks and their status.The query statement is as follows:
obclient(root@mysql001)[oceanbase]> SELECT JOB_ID, JOB_TYPE, STATUS FROM oceanbase.DBA_OB_BALANCE_JOBS;An example of the query result is as follows:
+--------+--------------------+---------+ | JOB_ID | JOB_TYPE | STATUS | +--------+--------------------+---------+ | 62944 | TRANSFER_PARTITION | DOING | +--------+--------------------+---------+ 1 row in setAccording to the query result, the status of the current balance job is
DOING, notCANCELING, so the job can be suspended.Execute the following statement to suspend the balance job.
obclient> ALTER SYSTEM SUSPEND BALANCE JOB;After the job is successfully suspended, query the
DBA_OB_BALANCE_JOBSview again. You will see that the status of the current task has changed toSUSPEND.The query statement is as follows:
obclient(root@mysql001)[oceanbase]> SELECT JOB_ID, JOB_TYPE, STATUS FROM oceanbase.DBA_OB_BALANCE_JOBS;An example of the query result is as follows:
+--------+--------------------+---------+ | JOB_ID | JOB_TYPE | STATUS | +--------+--------------------+---------+ | 62944 | TRANSFER_PARTITION | SUSPEND | +--------+--------------------+---------+ 1 row in set
Resume a suspended balance job
Resume a suspended balance job of a user tenant 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***** -ARetrieve tenant-related information.
obclient(root@sys)[oceanbase]> SELECT TENANT_ID, TENANT_NAME, TENANT_ROLE FROM oceanbase.DBA_OB_TENANTS WHERE tenant_name = 'mq_t1';The query result is as follows:
+-------------+-----------+-------------+ | TENANT_NAME | TENANT_ID | TENANT_ROLE | +-------------+-----------+-------------+ | mq_t1 | 1002 | PRIMARY | +-------------+-----------+-------------+ 1 row in setQuery the
CDB_OB_BALANCE_JOBSview for the status of the current suspended job.obclient(root@sys)[oceanbase]> SELECT TENANT_ID, JOB_ID, JOB_TYPE, STATUS FROM oceanbase.CDB_OB_BALANCE_JOBS WHERE TENANT_ID = 1002;An example of the query result is shown below:
+-----------+--------+--------------------+---------+ | TENANT_ID | JOB_ID | JOB_TYPE | STATUS | +-----------+--------+--------------------+---------+ | 1002 | 62944 | TRANSFER_PARTITION | SUSPEND | +-----------+--------+--------------------+---------+ 1 row in setAccording to the query result, the status of the current balance job is
SUSPEND.Execute the following statement to resume the suspended balance job.
ALTER SYSTEM SUSPEND BALANCE JOB TENANT = 'tenant_name';An example is shown below:
obclient(root@sys)[oceanbase]> ALTER SYSTEM RESUME BALANCE JOB TENANT ='mq_t1';After successful execution, query the
CDB_OB_BALANCE_JOBSview again, and you will see that the status of the current job has changed toDOING.obclient(root@sys)[oceanbase]> SELECT TENANT_ID, JOB_ID, JOB_TYPE, STATUS FROM oceanbase.CDB_OB_BALANCE_JOBS WHERE TENANT_ID = 1002;An example of the query result is shown below:
+-----------+--------+--------------------+---------+ | TENANT_ID | JOB_ID | JOB_TYPE | STATUS | +-----------+--------+--------------------+---------+ | 1002 | 62944 | TRANSFER_PARTITION | DOING | +-----------+--------+--------------------+---------+ 1 row in set
Resume a suspended balance job in the current tenant as 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_BALANCE_JOBSview for the status of the current suspended job.The query statement is as follows:
obclient(root@mysql001)[oceanbase]> SELECT JOB_ID, JOB_TYPE, STATUS FROM oceanbase.DBA_OB_BALANCE_JOBS;An example of the query result is shown below:
+--------+--------------------+---------+ | JOB_ID | JOB_TYPE | STATUS | +--------+--------------------+---------+ | 62944 | TRANSFER_PARTITION | SUSPEND | +--------+--------------------+---------+ 1 row in setAccording to the query result, the status of the current balance job is
SUSPEND.Execute the following statement to resume the suspended balance job.
obclient> ALTER SYSTEM RESUME BALANCE JOB;After successful execution, query the
DBA_OB_BALANCE_JOBSview again, and you can see that the current task status has changed toDOING.The query statement is as follows:
obclient(root@mysql001)[oceanbase]> SELECT JOB_ID, JOB_TYPE, STATUS FROM oceanbase.DBA_OB_BALANCE_JOBS;An example of the query result is as follows:
+--------+--------------------+---------+ | JOB_ID | JOB_TYPE | STATUS | +--------+--------------------+---------+ | 62944 | TRANSFER_PARTITION | DOING | +--------+--------------------+---------+ 1 row in set