After you execute the MAJOR FREEZE command, the system automatically schedules major compactions. Unlike OceanBase Database V2.x.x and V3.x.x, OceanBase Database V4.0.x and later versions use a unified compaction strategy. This strategy means that all zones of a tenant start major compactions simultaneously, and the major compaction of a tenant is considered complete only when all zones of the tenant have completed their major compactions.
During a major compaction, you do not need to manually control the order of major compactions in each zone, nor do you need to perform round-robin major compactions. If an error occurs during a major compaction, you can manually control the major compaction. For example, if a checksum error occurs, the major compaction of the current round for the tenant cannot be completed. In this case, you can pause the major compaction (suspend merge), fix the checksum error (for example, by manually repairing it), clear the checksum error (clear merge error), and then resume the major compaction (resume merge).
Prerequisites
Before manually controlling the major compaction, you must have triggered a major compaction by using the MAJOR FREEZE command. For more information about how to manually trigger a major compaction, see Manually trigger a major compaction.
Notes
A tenant-level major compaction can be initiated after a major compaction task is suspended, but a partition-level major compaction cannot be initiated. A tenant-level major compaction task that is initiated after a major compaction task is suspended is not executed immediately. Instead, the system executes this task after the major compaction is resumed.
Manually control major compactions in the system tenant
After a major compaction is initiated, the system tenant can control the major compactions for all tenants or for a specific tenant. The major compactions that can be controlled include tenant-level and partition-level major compactions.
The process is as follows:
Log in to the
systenant of the cluster as therootuser.Select the appropriate command control merge based on the actual business situation.
Pause all user tenants, all meta tenants, or specified tenants' major compactions
After you enable the major compactions, you can execute the following statements to stop major compactions for all user tenants, all META tenants, or a specified tenant.
Pause major compactions for all user tenants
ALTER SYSTEM SUSPEND MERGE TENANT = all_user;Or
ALTER SYSTEM SUSPEND MERGE TENANT = all;Note
Starting from OceanBase Database V4.2.1,
TENANT = all_userandTENANT = allhave the same semantics. To make the scope effective for all user tenants, we recommend that you useTENANT = all_user.TENANT = allwill be deprecated in the future.Stop minor compactions for all Meta tenants
ALTER SYSTEM SUSPEND MERGE TENANT = all_meta;Pause major compactions for the specified tenant
ALTER SYSTEM SUSPEND MERGE TENANT = tenant1,tenant2;
In this example,
=is optional. Replacetenant1andtenant2with the names of the actual tenants.Reconcile the merge
After you pause a major compaction, you can resume it by executing the statement.
Restore all merged data of the user tenants
ALTER SYSTEM RESUME MERGE TENANT = all_user;Or
ALTER SYSTEM RESUME MERGE TENANT = all;Note
Since OceanBase Database V4.2.1, the
TENANT = all_userandTENANT = allsettings are semantically the same. When you need to specify an effect scope of all user tenants, we recommend that you use theTENANT = all_usersetting. TheTENANT = allsetting will be deprecated.Resume major compactions for all Meta tenants
ALTER SYSTEM RESUME MERGE TENANT = all_meta;Restore compactions for a specific tenant
ALTER SYSTEM RESUME MERGE TENANT = tenant1,tenant2;
In this example,
=is optional. You need to replacetenant1andtenant2with the actual tenant names.Clear checksum error markings
If a checksum error occurs during a minor compaction and you manually repair the error, you can clear the checksum error to allow the compaction to proceed. Use the following statement:
Clear checksum errors for all user tenants
ALTER SYSTEM CLEAR MERGE ERROR TENANT = all_user;Or
ALTER SYSTEM CLEAR MERGE ERROR TENANT = all;Notes
Starting from OceanBase Database V4.2.1,
TENANT = all_userhas the same semantics asTENANT = all. When you want to specify all user tenants in a statement, we recommend that you useTENANT = all_user.TENANT = allwill be deprecated in later versions of OceanBase Database.Clean up the Checksum errors of all meta tenants.
ALTER SYSTEM CLEAR MERGE ERROR TENANT = all_meta;Clear the checksum error tag for the specified tenant
ALTER SYSTEM CLEAR MERGE ERROR TENANT = tenant1,tenant2;
=is optional; replacetenant1andtenant2with the actual names of the tenants.
Manually control compactions for a user tenant
After a major compaction starts, user tenants can control only compactions on their own tenants. User tenants can control major compactions for their own tenants and major compactions on partitions of their own tenants.
The tenant administrator for the user tenant logs in to the database.
Based on the business situation, select the appropriate command control merger.
Suspend the major compactions for the current tenant.
Once a merge starts for the current tenant, the following statements can be used to pause the merge.
obclient> ALTER SYSTEM SUSPEND MERGE;Restore merged data
After you stop a major compaction, you can also resume the major compaction.
The statement is as follows:
obclient> ALTER SYSTEM RESUME MERGE;Clean up the checksum error flag
If a checksum error occurs during a major compaction and you manually fix the issue, you can clear the checksum error flag to resume the compaction.
The statement is as follows:
obclient> ALTER SYSTEM CLEAR MERGE ERROR;
