Description
This statement is used to initiate a major compaction or minor compaction (freeze) in the system tenant. You can manually initiate a major compaction at the tenant or partition level, and you can manually initiate a minor compaction at the tenant, zone, server, log stream, or partition level.
Syntax
ALTER SYSTEM merge_action;
merge_action:
MAJOR FREEZE [tenant_list]
| MAJOR FREEZE tenant_list TABLET_ID = tablet_id
| MINOR FREEZE [tenant_list | TABLET_ID = tablet_id] [server_list] [zone_list] [LS [=] ls_id];
| {SUSPEND | RESUME} MERGE [tenant_list]
| CLEAR MERGE ERROR [tenant_list]
tenant_list:
TENANT [=] { all | all_user | all_meta } | tenant_name [, tenant_name ...]
server_list:
SERVER [=] ('ip:port' [, 'ip:port'...])
zone_list:
ZONE [=] ('zone_name' [, 'zone_name' ...]);
Parameter explanation
| Parameter | Description |
|---|---|
| MAJOR FREEZE | Initiates a major compaction on a daily basis. You can use the TENANT=all or TENANT=all_user parameter to specify to initiate a major compaction on all user tenants (excluding system and meta tenants). We recommend that you use the all_user parameter. The all parameter will be deprecated in the future; use the TENANT=all_meta parameter to specify to initiate a major compaction on all meta tenants. You can also use the TENANT=tenant_name [, tenant_name ...] parameter to specify to initiate a major compaction on the specified tenants. |
| MINOR FREEZE | Initiates a minor compaction. |
| {SUSPEND | RESUME} MERGE | Suspends or resumes a major compaction on a daily basis. You can use the TENANT=all or TENANT=all_user parameter to specify to suspend or resume major compactions on all tenants (excluding system and meta tenants). We recommend that you use the all_user parameter. The all parameter will be deprecated in the future; use the TENANT=all_meta parameter to specify to suspend or resume major compactions on all meta tenants. You can also use the TENANT=tenant_name [, tenant_name ...] parameter to specify to suspend or resume a major compaction on the specified tenants. |
| CLEAR MERGE ERROR | Clears the error flags of major compactions. You can use the TENANT=all or TENANT=all_user parameter to specify to clear the error flags of major compactions on all tenants (excluding system and meta tenants). We recommend that you use the all_user parameter. The all parameter will be deprecated in the future; use the TENANT=all_meta parameter to specify to clear the error flags of major compactions on all meta tenants. You can also use the TENANT=tenant_name [, tenant_name ...] parameter to specify to clear the error flags of major compactions on the specified tenants. |
| MAJOR FREEZE TENANT [=] tenant_name TABLET_ID = tablet_id | Specifies a tablet ID for a major compaction, namely, a partition-level major compaction.
NoteThis statement can be executed only in the sys tenant. |
| tenant_name | Specifies a tenant for a major or minor compaction. |
| TABLET_ID | Specifies a partition for a minor compaction. |
| SERVER | Specifies a server for a minor compaction. |
| ZONE | Specifies a zone for a minor compaction. |
| LS | Specifies a log stream for a minor compaction. |
Considerations
A tablet corresponds to a partition. Therefore, note the following considerations when you initiate a major compaction at the partition level:
- You cannot initiate a major compaction for a partition on which a tenant-level major compaction is being performed.
- You cannot initiate a major compaction for a partition on which an adaptive scheduling major compaction is being performed.
- You cannot initiate a major compaction for a partition where the replicas are inconsistent.
- You cannot initiate a major compaction for a partition that is under restoration or being transferred.
- You cannot initiate a major compaction if a previous major compaction is suspended.
- A major compaction at the partition level is actually a major compaction for multiple replicas of the same partition. This process consumes CPU and disk I/O resources. Therefore, before you perform a major compaction at the partition level, you need to assess the resource usage of your tenant. After the command executes successfully, the CPU and I/O usage will increase.
Examples
Examples of major compactions
Initiate a major compaction of the system tenant on a daily basis.
obclient> ALTER SYSTEM MAJOR FREEZE; Query OK, 0 rows affectedInitiate a major compaction of all user tenants (excluding the system and metadata tenants).
obclient> ALTER SYSTEM MAJOR FREEZE TENANT = all_user; Query OK, 0 rows affectedInitiate a major compaction of all metadata tenants.
obclient> ALTER SYSTEM MAJOR FREEZE TENANT = all_meta; Query OK, 0 rows affectedInitiate major compactions of the
tenant1andtenant2tenants.obclient> ALTER SYSTEM MAJOR FREEZE TENANT = tenant1,tenant2; Query OK, 0 rows affected
Examples of minor compactions
Initiate a minor compaction of the system tenant.
obclient> ALTER SYSTEM MINOR FREEZE; Query OK, 0 rows affectedInitiate a minor compaction of all user tenants (excluding the system and metadata tenants).
obclient> ALTER SYSTEM MINOR FREEZE TENANT = all_user; Query OK, 0 rows affectedInitiate a minor compaction of all metadata tenants.
obclient> ALTER SYSTEM MINOR FREEZE TENANT = all_meta; Query OK, 0 rows affectedInitiate minor compactions of the
tenant1andtenant2tenants.obclient> ALTER SYSTEM MINOR FREEZE TENANT = tenant1,tenant2; Query OK, 0 rows affectedInitiate a minor compaction of a specified partition in the
tenant1tenant.obclient> ALTER SYSTEM MINOR FREEZE tenant = tenant1 tablet_id = 1100611139453887; Query OK, 0 rows affectedInitiate a minor compaction of a specified OBServer node.
obclient> ALTER SYSTEM MINOR FREEZE SERVER = ('10.XXX.XXX.XXX:2882'); Query OK, 0 rows affectedInitiate a minor compaction of a specified log stream in the
tenant1tenant.obclient> ALTER SYSTEM MINOR FREEZE tenant = t1 LS 1; Query OK, 0 rows affectedInitiate a minor compaction of a specified partition in a specified log stream in the
tenant1tenant.obclient> ALTER SYSTEM MINOR FREEZE tenant = t1 ls 1 tablet_id = 60000; Query OK, 0 rows affected
Examples of suspending and resuming daily major compactions
Suspend daily major compactions of all user tenants (excluding the system and metadata tenants).
obclient> ALTER SYSTEM SUSPEND MERGE TENANT = all_user; Query OK, 0 rows affectedSuspend daily major compactions of the
tenant1andtenant2tenants.obclient> ALTER SYSTEM SUSPEND MERGE TENANT = tenant1,tenant2; Query OK, 0 rows affectedSuspend daily major compactions of all metadata tenants.
obclient> ALTER SYSTEM SUSPEND MERGE TENANT = all_meta; Query OK, 0 rows affectedResume daily major compactions of all user tenants (excluding the system and metadata tenants).
obclient> ALTER SYSTEM RESUME MERGE TENANT = all_user; Query OK, 0 rows affectedResume daily major compactions of the
tenant1andtenant2tenants.obclient> ALTER SYSTEM RESUME MERGE TENANT = tenant1,tenant2; Query OK, 0 rows affectedResume daily major compactions of all metadata tenants.
obclient> ALTER SYSTEM RESUME MERGE TENANT = all_meta; Query OK, 0 rows affected
Examples of purging error markers
Purge error markers of minor compactions of all user tenants (excluding the system and metadata tenants).
obclient> ALTER SYSTEM CLEAR MERGE ERROR TENANT = all_user; Query OK, 0 rows affectedPurge error markers of minor compactions of the
tenant1andtenant2tenants.obclient> ALTER SYSTEM CLEAR MERGE ERROR TENANT = tenant1,tenant2; Query OK, 0 rows affectedPurge error markers of minor compactions of all metadata tenants.
obclient> ALTER SYSTEM CLEAR MERGE ERROR TENANT = all_meta; Query OK, 0 rows affected
Initiate a major compaction at the partition level
Query the TABLET ID of the table.
Here is an example:
SELECT t1.tenant_id, t2.tenant_name, t1.database_name, t1.table_id, t1.table_name, t1.tablet_id, t1.PARTITION_NAME, t1.SUBPARTITION_NAME FROM oceanbase.CDB_OB_TABLE_LOCATIONS t1, oceanbase.DBA_OB_TENANTS t2 WHERE t1.tenant_id=t2.tenant_id AND t1.table_name = 'test_tbl1' AND t2.tenant_name = 'oracle001';The return result is as follows:
+-----------+-------------+---------------+----------+------------+-----------+----------------+-------------------+ | tenant_id | tenant_name | database_name | table_id | table_name | tablet_id | PARTITION_NAME | SUBPARTITION_NAME | +-----------+-------------+---------------+----------+------------+-----------+----------------+-------------------+ | 1004 | oracle001 | SYS | 500011 | TEST_TBL1 | 200008 | P1 | SP0 | | 1004 | oracle001 | SYS | 500011 | TEST_TBL1 | 200009 | P1 | SP1 | | 1004 | oracle001 | SYS | 500011 | TEST_TBL1 | 200010 | P1 | SP2 | | 1004 | oracle001 | SYS | 500011 | TEST_TBL1 | 200011 | P1 | SP3 | | 1004 | oracle001 | SYS | 500011 | TEST_TBL1 | 200012 | P2 | SP4 | | 1004 | oracle001 | SYS | 500011 | TEST_TBL1 | 200013 | P2 | SP5 | | 1004 | oracle001 | SYS | 500011 | TEST_TBL1 | 200014 | P2 | SP6 | | 1004 | oracle001 | SYS | 500011 | TEST_TBL1 | 200015 | P2 | SP7 | +-----------+-------------+---------------+----------+------------+-----------+----------------+-------------------+ 8 rows in setFor more information about the view columns, see oceanbase.CDB_OB_TABLE_LOCATIONS.
Initiate a major compaction.
Here is an example:
ALTER SYSTEM MAJOR FREEZE TENANT = oracle001 TABLET_ID = 200008;The return result is as follows:
Query OK, 0 rows affected
Initiate a minor compaction at the partition level
Query the TABLET ID of the table.
Here is an example:
SELECT t1.tenant_id, t2.tenant_name, t1.database_name, t1.table_id, t1.table_name, t1.tablet_id, t1.PARTITION_NAME, t1.SUBPARTITION_NAME FROM oceanbase.CDB_OB_TABLE_LOCATIONS t1, oceanbase.DBA_OB_TENANTS t2 WHERE t1.tenant_id=t2.tenant_id AND t1.table_name = 'test_tbl1' AND t2.tenant_name = 'oracle001';The return result is as follows:
+-----------+-------------+---------------+----------+------------+-----------+----------------+-------------------+ | tenant_id | tenant_name | database_name | table_id | table_name | tablet_id | PARTITION_NAME | SUBPARTITION_NAME | +-----------+-------------+---------------+----------+------------+-----------+----------------+-------------------+ | 1004 | oracle001 | SYS | 500011 | TEST_TBL1 | 200008 | P1 | SP0 | | 1004 | oracle001 | SYS | 500011 | TEST_TBL1 | 200009 | P1 | SP1 | | 1004 | oracle001 | SYS | 500011 | TEST_TBL1 | 200010 | P1 | SP2 | | 1004 | oracle001 | SYS | 500011 | TEST_TBL1 | 200011 | P1 | SP3 | | 1004 | oracle001 | SYS | 500011 | TEST_TBL1 | 200012 | P2 | SP4 | | 1004 | oracle001 | SYS | 500011 | TEST_TBL1 | 200013 | P2 | SP5 | | 1004 | oracle001 | SYS | 500011 | TEST_TBL1 | 200014 | P2 | SP6 | | 1004 | oracle001 | SYS | 500011 | TEST_TBL1 | 200015 | P2 | SP7 | +-----------+-------------+---------------+----------+------------+-----------+----------------+-------------------+ 8 rows in setFor more information about the view columns, see oceanbase.CDB_OB_TABLE_LOCATIONS.
Initiate a minor compaction.
Here is an example:
ALTER SYSTEM MINOR FREEZE TENANT = oracle001 TABLET_ID = 200008;The return result is as follows:
Query OK, 0 rows affected