Cancel a load balancing job

2025-01-02 01:58:39  Updated

Each tenant can have only one running load balancing job at a time. You can cancel an ongoing load balancing job if it does not meet your business needs or if you want to schedule a manually initiated partition transfer task as soon as possible.

Limitations

You can cancel load balancing jobs only in primary databases or tenants.

Background information

Each tenant can have only one running load balancing job at a time, such as a scale-out, scale-in, log stream migration, or partition balancing job. A load balancing job generates multiple load balancing tasks for specific load balancing operations. Canceling a load balancing job cancels all ongoing tasks in the job.

Cancel a load balancing job in the sys tenant

  1. Log in to the sys tenant of the cluster as the root user.

    Note that you must specify the corresponding parameters in the following sample code based on your actual database configurations.

    obclient -h10.xx.xx.xx -P2883 -uroot@sys#obdemo -p***** -A
    
  2. Query the CDB_OB_BALANCE_JOBS view for the status of the current job.

    obclient [oceanbase]> SELECT * FROM oceanbase.CDB_OB_BALANCE_JOBS WHERE TENANT_ID = 1002;
    

    A sample query result is as follows:

    +-----------+--------+----------------------------+----------------------------+----------------------+------------+-----------------+-------------------------+--------+---------+
    | TENANT_ID | JOB_ID | CREATE_TIME                | MODIFY_TIME                | BALANCE_STRATEGY     | JOB_TYPE   | TARGET_UNIT_NUM | TARGET_PRIMARY_ZONE_NUM | STATUS | COMMENT |
    +-----------+--------+----------------------------+----------------------------+----------------------+------------+-----------------+-------------------------+--------+---------+
    |      1002 | 520683 | 2023-11-01 14:56:28.552867 | 2023-11-01 14:56:28.552867 | LS balance by shrink | LS_BALANCE |               1 |                       1 | DOING  | NULL    |
    +-----------+--------+----------------------------+----------------------------+----------------------+------------+-----------------+-------------------------+--------+---------+
    1 row in set
    
  3. If the query result shows that the job does not meet your expectation, execute the following statement to cancel it:

    ALTER SYSTEM CANCEL BALANCE JOB TENANT = 'tenant_name';
    

    Here is an example:

    obclient [oceanbase]> ALTER SYSTEM CANCEL BALANCE JOB TENANT ='mysql_tenant';
    

Cancel a load balancing job in a user tenant

  1. Connect to the database as the tenant administrator of a MySQL or Oracle tenant.

    Note that you must specify the corresponding parameters in the following sample code based on your actual database configurations.

    obclient -h10.xx.xx.xx -P2883 -uroot@mysql_tenant#obdemo -p***** -A
    
  2. Query the DBA_OB_BALANCE_JOBS view for the status of the current job.

    MySQL mode
    Oracle mode

    Execute the following statement in MySQL mode:

    obclient [oceanbase]> SELECT * FROM oceanbase.DBA_OB_BALANCE_JOBS;
    

    Execute the following statement in Oracle mode:

    obclient [SYS]> SELECT * FROM SYS.DBA_OB_BALANCE_JOBS;
    
  3. If the query result shows that the job does not meet your expectation, execute the following statement to cancel it:

    obclient> ALTER SYSTEM CANCEL BALANCE JOB;
    

References

Contact Us