In addition to the scheduled partition balancing task, you can manually trigger partition balancing by calling the TRIGGER_PARTITION_BALANCE subprogram in the DBMS_BALANCE system package.
Limitations
You can manually trigger partition balancing only in a user tenant, not in the sys tenant.
Considerations
If another balancing task is in progress in the system, you cannot manually trigger a partition balancing task. You must wait until the current balancing task is completed.
In the sys tenant, you can query the CDB_OB_BALANCE_JOBS view to check whether other balancing tasks are in progress for a specified tenant. In a user tenant, you can query the DBA_OB_BALANCE_JOBS view to check whether balancing tasks are in progress.
Before manually triggering partition balancing, make sure that the tenant-level parameters
enable_rebalanceandenable_transferare both set toTrue. If either of them is notTrue, the statement for manually triggering partition balancing fails to be executed.If partitions of the current tenant are already balanced, the system returns the following error:
partitions are already balanced, no need to trigger partition balance.
Manually trigger a one-time partition balancing
Log in to the user tenant of the cluster as a tenant administrator.
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***** -ACall the
TRIGGER_PARTITION_BALANCEsubprogram in theDBMS_BALANCEsystem package to trigger a one-time partition balancing.The statement is as follows:
CALL DBMS_BALANCE.TRIGGER_PARTITION_BALANCE(balance_timeout);Here,
balance_timeoutcontrols the timeout period for the background partition balancing task, in seconds. If this value is not specified, it means there is no timeout for background partition balancing tasks, including those triggered manually or scheduled, and they will continue until completion.Here are some examples:
Trigger a one-time partition balancing with no timeout for the background task.
obclient [oceanbase]> CALL DBMS_BALANCE.TRIGGER_PARTITION_BALANCE();Trigger a one-time partition balancing with a background task timeout of 7200 seconds.
obclient [oceanbase]> CALL DBMS_BALANCE.TRIGGER_PARTITION_BALANCE(7200);
For more information about the
TRIGGER_PARTITION_BALANCEsubprogram in theDBMS_BALANCEsystem package, see TRIGGER_PARTITION_BALANCE.
What to do next
After you manually trigger partition balancing, the actual partition transfer is performed asynchronously by the background balancing task. You can view the execution progress of the partition balancing task by querying a view. For more information, see View background partition balancing tasks.