Manually control a major compaction

2023-08-01 06:02:28  Updated

After you use the MAJOR FREEZE statement to initiate a major compaction, the system automatically schedules the major compaction task. Unlike OceanBase Database V2.X.X and V3.X.X, OceanBase Database V4.0.X uses a unified major compaction strategy to implement the major compaction process. In other words, a major compaction is performed for all zones of the tenant at the same time. When the major compaction is completed for all zones, the major compaction is considered completed for the tenant.

During the major compaction, you do not need to manually control the compaction sequence of the zones and rotating compaction is not involved. If an error occurs during the major compaction, you can manually control the major compaction. For example, if a checksum verification error occurs, the current major compaction for the tenant cannot end. In this case, you can suspend the current major compaction. After the checksum resumes normal as a result of manual intervention, you can clear the checksum error tag and resume the major compaction.

Manually control a major compaction from the sys tenant

After a major compaction begins, you can control the major compaction for all tenants or specified tenants from the sys tenant.

Procedure:

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

  2. Perform the following steps to control the major compaction based on the actual situation.

    • Suspend the major compaction for all tenants or specified tenants

      After the major compaction begins, you can suspend the major compaction for all tenants or specified tenants.

      Sample statement:

      obclient> ALTER SYSTEM SUSPEND MERGE TENANT [=] ALL;
      
      obclient> ALTER SYSTEM SUSPEND MERGE TENANT [=] tenant1,tenant2;
      

      [=] indicates that the equal sign (=) is optional. You must replace tenant1 andtenant2 with their actual tenant names.

    • Resume a major compaction

      After a major compaction is suspended, you can resume it.

      Sample statement:

      obclient> ALTER SYSTEM RESUME MERGE TENANT [=] ALL;
      
      obclient> ALTER SYSTEM RESUME MERGE TENANT [=] tenant1,tenant2;
      

      [=] indicates that the equal sign (=) is optional. You must replace tenant1 andtenant2 with their actual tenant names.

    • Clear the checksum error tag

      If a checksum verification error occurs during a major compaction and is resolved after manual intervention, you can clear this checksum error tag and resume the major compaction.

      Sample statement:

      obclient> ALTER SYSTEM CLEAR MERGE ERROR TENANT [=] ALL;
      
      obclient> ALTER SYSTEM CLEAR MERGE ERROR TENANT [=] tenant1,tenant2;
      

      [=] indicates that the equal sign (=) is optional. You must replace tenant1 andtenant2 with their actual tenant names.

Manually control a major compaction from a user tenant

After the major compaction begins, a user tenant can control the major compaction only for itself.

  1. Log on to OceanBase Database as the administrator of the user tenant.

  2. Perform the following steps to control the major compaction based on the actual situation.

    • Suspend the major compaction for the current tenant

      To suspend the major compaction for the current tenant, execute the following statement:

      obclient> ALTER SYSTEM SUSPEND MERGE;
      
    • Resume a major compaction

      After a major compaction is suspended, you can resume it.

      Sample statement:

      obclient> ALTER SYSTEM RESUME MERGE;
      
    • Clear the checksum error tag

      If a checksum verification error occurs during a major compaction and is resolved after manual intervention, you can clear this checksum error tag and resume the major compaction.

      Sample statement:

      obclient> ALTER SYSTEM CLEAR MERGE ERROR;
      

More information

Contact Us