After you trigger a major compaction by using the MAJOR FREEZE command, the system automatically schedules the compaction task. The major compaction is executed using a unified strategy: all zones of a tenant start the compaction simultaneously, and the tenant's major compaction is considered complete only after all zones are finished.
During the major compaction, you do not need to manually control the compaction order of individual zones, nor is there any rotation. If an error occurs during the major compaction, you can refer to this topic to manually control it. For example, if a checksum error prevents the current round of compaction for a tenant from ending, you can suspend the current compaction (suspend merge). After the checksum error is corrected (for example, through manual intervention), you can clear the merge error flag (clear merge error), and then resume the current round of compaction (resume merge).
Prerequisites
Before manually controlling a major compaction, ensure that you have triggered it using the MAJOR FREEZE command. For detailed steps on manually triggering a major compaction, see Manually trigger a major compaction.
Considerations
When a major compaction task is suspended, tenant-level compactions are allowed, but partition-level compactions are not. For a tenant-level compaction initiated while the major compaction task is suspended, the system does not execute it immediately; instead, it waits until the major compaction resumes before executing the tenant-level compaction.
Manually control a major compaction in the sys tenant
After a major compaction starts, the sys tenant can control major compactions for all tenants or specified tenants, including tenant-level major compactions and partition-level major compactions.
The procedure is as follows:
Log in to the
systenant of the cluster as therootuser.Select the appropriate command to control the compaction based on your business requirements.
Suspend major compactions for all user tenants, all Meta tenants, or specified tenants
After a major compaction starts, if you need to suspend it for all user tenants, all Meta tenants, or specified tenants, execute the following statements.
Suspend major compactions for all user tenants
ALTER SYSTEM SUSPEND MERGE TENANT = all_user;Or
ALTER SYSTEM SUSPEND MERGE TENANT = all;Note
TENANT = all_userhas the same semantics asTENANT = all. When the scope needs to cover all user tenants, we recommend usingTENANT = all_user.TENANT = allwill be deprecated in the future.Suspend major compactions for all Meta tenants
ALTER SYSTEM SUSPEND MERGE TENANT = all_meta;Suspend major compactions for specified tenants
ALTER SYSTEM SUSPEND MERGE TENANT = tenant1,tenant2;
Here,
=is optional. Replacetenant1andtenant2with the actual tenant names.Resume a major compaction
After a major compaction is suspended, you can resume it by using the following statements.
Resume the major compaction for all user tenants
ALTER SYSTEM RESUME MERGE TENANT = all_user;Or
ALTER SYSTEM RESUME MERGE TENANT = all;Note
TENANT = all_userhas the same semantics asTENANT = all. When the scope needs to cover all user tenants, we recommend usingTENANT = all_user.TENANT = allwill be deprecated in the future.Resume major compactions for all Meta tenants
ALTER SYSTEM RESUME MERGE TENANT = all_meta;Resume major compactions for specified tenants
ALTER SYSTEM RESUME MERGE TENANT = tenant1,tenant2;
Here,
=is optional. Replacetenant1andtenant2with the actual tenant names.Clear checksum error flags
If a checksum verification error occurs during a major compaction and is manually fixed, you can clear the checksum error flag to resume the major compaction by using the following statements.
Clear checksum error flags for all user tenants
ALTER SYSTEM CLEAR MERGE ERROR TENANT = all_user;Or
ALTER SYSTEM CLEAR MERGE ERROR TENANT = all;Note
TENANT = all_userhas the same semantics asTENANT = all. When the scope needs to cover all user tenants, we recommend usingTENANT = all_user.TENANT = allwill be deprecated in the future.Clear checksum error flags for all Meta tenants
ALTER SYSTEM CLEAR MERGE ERROR TENANT = all_meta;Clear checksum error flags for specified tenants
ALTER SYSTEM CLEAR MERGE ERROR TENANT = tenant1,tenant2;
Here,
=is optional;tenant1andtenant2must be replaced with the actual tenant names.
Manually control a major compaction in a user tenant
After a major compaction starts, a user tenant can control major compactions only for itself, including tenant-level major compactions and partition-level major compactions.
Log in to the database as the tenant administrator of the user tenant.
Select the appropriate command to control the major compaction based on your business needs.
Suspend the major compaction for the current tenant
After a major compaction starts, if you need to suspend it for the current tenant, execute the following statement:
obclient> ALTER SYSTEM SUSPEND MERGE;Resume the major compaction
After a major compaction is suspended, you can resume it.
The statement is as follows:
obclient> ALTER SYSTEM RESUME MERGE;Clear the checksum error flag
If a checksum verification error occurs during the major compaction and is manually fixed, you can clear the checksum error flag to resume the major compaction.
The statement is as follows:
obclient> ALTER SYSTEM CLEAR MERGE ERROR;