Description
This statement is used to initiate major compactions or minor compactions (freezes) in the system tenant. Manual major compactions are supported at the tenant level only. Manual minor compactions are supported at the tenant level, zone level, server level, log stream level, and partition level.
Syntax
ALTER SYSTEM merge_action;
merge_action:
MAJOR FREEZE [tenant_list]
| MAJOR FREEZE [tenant_list]
| MINOR FREEZE [tenant_list | server_list | zone_list | {TENANT [=] tenant_name LS [=] ls_id} | {TENANT [=] tenant_name TABLET_ID = tablet_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. You can use TENANT=all or TENANT=all_user to specify all user tenants (excluding the sys and meta tenants). We recommend that you use all_user. all will be deprecated in the future. You can use TENANT=all_meta to specify all meta tenants. You can also use TENANT=tenant_name [, tenant_name ...] to specify only the desired tenants. |
| MINOR FREEZE | Initiates a minor compaction. |
| {SUSPEND | RESUME} MERGE | Suspends or resumes a daily major compaction. You can use TENANT=all or TENANT=all_user to suspend or resume daily major compactions for all user tenants (excluding the sys and meta tenants). We recommend that you use all_user. all will be deprecated in the future. You can use TENANT=all_meta to suspend or resume daily major compactions for all meta tenants. You can also use TENANT=tenant_name [, tenant_name ...] to suspend or resume daily major compactions for the specified tenants. |
| CLEAR MERGE ERROR | Clears the error flag of a major compaction. You can use TENANT=all or TENANT=all_user to clear the error flags of major compactions for all user tenants (excluding the sys and meta tenants). We recommend that you use all_user. all will be deprecated in the future. You can use TENANT=all_meta to clear the error flags of major compactions for all meta tenants. You can also use TENANT=tenant_name [, tenant_name ...] to clear the error flags of major compactions for the specified tenants. |
| MAJOR FREEZE TENANT [=] tenant_name | Specifies the tenant for which a major compaction is to be performed.
NoteThis statement can be executed only in the sys tenant. |
| tenant_name | Specifies the tenant for which a major compaction or a minor compaction is to be performed. |
| TABLET_ID | Specifies a tablet for minor compaction. |
| SERVER | Specifies a server for minor compaction. |
| ZONE | Specifies a zone for minor compaction. |
| LS | Specifies a log stream for minor compaction. |
Example
Examples of major compactions
Initiate a daily major compaction for the sys tenant.
obclient> ALTER SYSTEM MAJOR FREEZE; Query OK, 0 rows affectedInitiate major compactions for all user tenants (excluding the sys and meta tenants) for the sys tenant.
obclient> ALTER SYSTEM MAJOR FREEZE TENANT = all_user; Query OK, 0 rows affectedInitiate major compactions for all meta tenants for the sys tenant.
obclient> ALTER SYSTEM MAJOR FREEZE TENANT = all_meta; Query OK, 0 rows affectedInitiate major compactions for specified tenants
tenant1andtenant2for the sys tenant.obclient> ALTER SYSTEM MAJOR FREEZE TENANT = tenant1,tenant2; Query OK, 0 rows affected
Examples of minor compactions
Initiate a minor compaction for the sys tenant.
obclient> ALTER SYSTEM MINOR FREEZE; Query OK, 0 rows affectedInitiate minor compactions for all user tenants (excluding the sys and meta tenants) for the sys tenant.
obclient> ALTER SYSTEM MINOR FREEZE TENANT = all_user; Query OK, 0 rows affectedInitiate minor compactions for all meta tenants for the sys tenant.
obclient> ALTER SYSTEM MINOR FREEZE TENANT = all_meta; Query OK, 0 rows affectedInitiate minor compactions for specified tenants
tenant1andtenant2for the sys tenant.obclient> ALTER SYSTEM MINOR FREEZE TENANT = tenant1,tenant2; Query OK, 0 rows affectedInitiate a minor compaction for specified partitions of tenant
tenant1.obclient> ALTER SYSTEM MINOR FREEZE tenant = tenant1 tablet_id = 1100611139453887; Query OK, 0 rows affectedInitiate a minor compaction for a specified OBServer.
obclient> ALTER SYSTEM MINOR FREEZE SERVER = ('10.XXX.XXX.XXX:2882'); Query OK, 0 rows affectedInitiate a minor compaction for specified log streams of a specified tenant.
obclient> ALTER SYSTEM MINOR FREEZE tenant = t1 LS 1; Query OK, 0 rows affectedInitiate a minor compaction for specified partitions of a specified log stream of a specified tenant.
obclient> ALTER SYSTEM MINOR FREEZE tenant = t1 ls 1 tablet_id = 60000; Query OK, 0 rows affected
Examples of pausing and resuming daily major compactions
Pause daily major compactions for all user tenants (excluding the sys and meta tenants) for the sys tenant.
obclient> ALTER SYSTEM SUSPEND MERGE TENANT = all_user; Query OK, 0 rows affectedPause daily major compactions for specified tenants
tenant1andtenant2for the sys tenant.obclient> ALTER SYSTEM SUSPEND MERGE TENANT = tenant1,tenant2; Query OK, 0 rows affectedPause daily major compactions for all meta tenants for the sys tenant.
obclient> ALTER SYSTEM SUSPEND MERGE TENANT = all_meta; Query OK, 0 rows affectedResume daily major compactions for all user tenants (excluding the sys and meta tenants) for the sys tenant.
obclient> ALTER SYSTEM RESUME MERGE TENANT = all_user; Query OK, 0 rows affectedResume daily major compactions for specified tenants
tenant1andtenant2for the sys tenant.obclient> ALTER SYSTEM RESUME MERGE TENANT = tenant1,tenant2; Query OK, 0 rows affectedResume daily major compactions for all meta tenants for the sys tenant.
obclient> ALTER SYSTEM RESUME MERGE TENANT = all_meta; Query OK, 0 rows affected
Examples of cleaning up error flags for major compactions
Clean up error flags for major compactions for all user tenants (excluding the sys and meta tenants) for the sys tenant.
obclient> ALTER SYSTEM CLEAR MERGE ERROR TENANT = all_user; Query OK, 0 rows affectedClean up error flags for major compactions for specified tenants
tenant1andtenant2for the sys tenant.obclient> ALTER SYSTEM CLEAR MERGE ERROR TENANT = tenant1,tenant2; Query OK, 0 rows affectedClean up error flags for major compactions for all meta tenants for the sys tenant.
obclient> ALTER SYSTEM CLEAR MERGE ERROR TENANT = all_meta; Query OK, 0 rows affected
Initiate a minor compaction at the partition level
Query the table 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