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. 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 daily major compaction. You can use the TENANT=all or TENANT=all_user parameter to specify to initiate a major compaction for 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 TENANT=all_meta to specify to initiate a major compaction for all meta tenants; or use TENANT=tenant_name [, tenant_name ...] to specify to initiate a major compaction for the specified tenants. |
| MINOR FREEZE | Initiates a minor compaction. |
| {SUSPEND | RESUME} MERGE | Suspends or resumes the daily major compaction. You can use the TENANT=all or TENANT=all_user parameter to specify to suspend or resume the daily major compaction for 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 TENANT=all_meta to specify to suspend or resume the daily major compaction for all meta tenants; or use TENANT=tenant_name [, tenant_name ...] to specify to suspend or resume the daily major compaction for 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 for 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 TENANT=all_meta to specify to clear the error flags of major compactions for all meta tenants; or use TENANT=tenant_name [, tenant_name ...] to specify to clear the error flags of major compactions for the specified tenants. |
| MAJOR FREEZE TENANT [=] tenant_name TABLET_ID = tablet_id | Specifies the tablet ID to initiate a major compaction. This statement can be used to initiate a major compaction at the partition level.
NoteThis statement can be executed only in the sys tenant. |
| tenant_name | The name of the tenant for a major or minor compaction. |
| TABLET_ID | The ID of the partition for a major or minor compaction. |
| SERVER | The name of the server for a minor compaction. |
| ZONE | The name of the zone for a minor compaction. |
| LS | The name of the log stream for a minor compaction. |
Considerations
A tablet corresponds to a partition. Consider the following points 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 major compaction is being performed.
- You cannot initiate a major compaction for a partition where the multi-replica data is inconsistent.
- You cannot initiate a major compaction for a partition that is being restored or transferred.
- You cannot initiate a major compaction if the current 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. Before you initiate a major compaction at the partition level, you need to assess the resource usage of the current tenant. After the major compaction completes, the CPU and I/O usage will increase.
Example
Examples of major compactions
Initiate a major compaction in the system tenant on a daily basis.
obclient> ALTER SYSTEM MAJOR FREEZE; Query OK, 0 rows affectedInitiate a major compaction in the system tenant for all user tenants (excluding the system and meta tenants).
obclient> ALTER SYSTEM MAJOR FREEZE TENANT = all_user; Query OK, 0 rows affectedInitiate a major compaction in the system tenant for all meta tenants.
obclient> ALTER SYSTEM MAJOR FREEZE TENANT = all_meta; Query OK, 0 rows affectedInitiate a major compaction in the system tenant for the
tenant1andtenant2tenants.obclient> ALTER SYSTEM MAJOR FREEZE TENANT = tenant1,tenant2; Query OK, 0 rows affected
Examples of minor compactions
Initiate a minor compaction in the system tenant on a daily basis.
obclient> ALTER SYSTEM MINOR FREEZE; Query OK, 0 rows affectedInitiate a minor compaction in the system tenant for all user tenants (excluding the system and meta tenants).
obclient> ALTER SYSTEM MINOR FREEZE TENANT = all_user; Query OK, 0 rows affectedInitiate a minor compaction in the system tenant for all meta tenants.
obclient> ALTER SYSTEM MINOR FREEZE TENANT = all_meta; Query OK, 0 rows affectedInitiate a minor compaction in the system tenant for the
tenant1andtenant2tenants.obclient> ALTER SYSTEM MINOR FREEZE TENANT = tenant1,tenant2; Query OK, 0 rows affectedInitiate a minor compaction in the system tenant for a specified partition in the
tenant1tenant.obclient> ALTER SYSTEM MINOR FREEZE tenant = tenant1 tablet_id = 1100611139453887; Query OK, 0 rows affectedInitiate a minor compaction in the system tenant for a specified OBServer node.
obclient> ALTER SYSTEM MINOR FREEZE SERVER = ('10.XXX.XXX.XXX:2882'); Query OK, 0 rows affectedInitiate a minor compaction in the system tenant for a specified log stream in the
tenant1tenant.obclient> ALTER SYSTEM MINOR FREEZE tenant = t1 LS 1; Query OK, 0 rows affectedInitiate a minor compaction in the system tenant for 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 major compactions on a daily basis for all user tenants (excluding the system and meta tenants) in the system tenant.
obclient> ALTER SYSTEM SUSPEND MERGE TENANT = all_user; Query OK, 0 rows affectedSuspend major compactions on a daily basis for the
tenant1andtenant2tenants in the system tenant.obclient> ALTER SYSTEM SUSPEND MERGE TENANT = tenant1,tenant2; Query OK, 0 rows affectedSuspend major compactions on a daily basis for all meta tenants in the system tenant.
obclient> ALTER SYSTEM SUSPEND MERGE TENANT = all_meta; Query OK, 0 rows affectedResume major compactions on a daily basis for all user tenants (excluding the system and meta tenants) in the system tenant.
obclient> ALTER SYSTEM RESUME MERGE TENANT = all_user; Query OK, 0 rows affectedResume major compactions on a daily basis for the
tenant1andtenant2tenants in the system tenant.obclient> ALTER SYSTEM RESUME MERGE TENANT = tenant1,tenant2; Query OK, 0 rows affectedResume major compactions on a daily basis for all meta tenants in the system tenant.
obclient> ALTER SYSTEM RESUME MERGE TENANT = all_meta; Query OK, 0 rows affected
Examples of clearing error markers from major compactions
Clear the error markers from major compactions for all user tenants (excluding the system and meta tenants) in the system tenant.
obclient> ALTER SYSTEM CLEAR MERGE ERROR TENANT = all_user; Query OK, 0 rows affectedClear the error markers from major compactions for the
tenant1andtenant2tenants in the system tenant.obclient> ALTER SYSTEM CLEAR MERGE ERROR TENANT = tenant1,tenant2; Query OK, 0 rows affectedClear the error markers from major compactions for all meta tenants in the system tenant.
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 IDs 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 IDs 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