Purpose
This statement is used to initiate a major freeze (storage layer major compaction) or minor freeze (storage layer minor compaction) for the system tenant. Manual major compactions can be performed at the tenant, table, or partition level. Manual minor compactions can be performed at the tenant, zone, server, log stream, or partition level.
Syntax
ALTER SYSTEM merge_action;
merge_action:
MAJOR FREEZE [tenant_list]
| MAJOR FREEZE TENANT [=] tenant_name {TABLE_ID = table_id | TABLET_ID = tablet_id}
| MINOR FREEZE [tenant_list | server_list | zone_list]
| MINOR FREEZE TENANT [=] tenant_name [LS [=] ls_id] [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' ...])
Parameters
| Parameter | Description |
|---|---|
| MAJOR FREEZE | Initiates a major freeze (storage layer major compaction). Use TENANT=all or TENANT=all_user to initiate a major freeze for all user tenants (excluding the system tenant and Meta tenant). We recommend that you use all_user. The all option will be deprecated in the future. Use TENANT=all_meta to initiate a major freeze for all Meta tenants. You can also use TENANT=tenant_name [, tenant_name ...] to initiate a major freeze for specified tenants. |
| MINOR FREEZE | Initiates a minor freeze (storage layer minor compaction). |
| {SUSPEND | RESUME} MERGE | Suspends or resumes a major freeze (storage layer major compaction). Use TENANT=all or TENANT=all_user to suspend or resume a major freeze for all user tenants (excluding the system tenant and Meta tenant). We recommend that you use all_user. The all option will be deprecated in the future. Use TENANT=all_meta to suspend or resume a major freeze for all Meta tenants. You can also use TENANT=tenant_name [, tenant_name ...] to suspend or resume a major freeze for specified tenants. |
| CLEAR MERGE ERROR | Clears the error flag of a major freeze (storage layer major compaction). Use TENANT=all or TENANT=all_user to clear the error flag of a major freeze for all user tenants (excluding the system tenant and Meta tenant). We recommend that you use all_user. The all option will be deprecated in the future. Use TENANT=all_meta to clear the error flag of a major freeze for all Meta tenants. You can also use TENANT=tenant_name [, tenant_name ...] to clear the error flag of a major freeze for specified tenants. |
| tenant_name | Specifies the tenant for a major freeze (storage layer major compaction) or minor freeze (storage layer minor compaction). |
| TABLE_ID | Specifies the table for a major freeze (storage layer major compaction). |
| TABLET_ID | Specifies the partition for a major freeze (storage layer major compaction) or minor freeze (storage layer minor compaction). |
| SERVER | Specifies the server for a minor freeze (storage layer minor compaction). |
| ZONE | Specifies the zone for a minor freeze (storage layer minor compaction). |
| LS | Specifies the log stream for a minor freeze (storage layer minor compaction). |
Considerations
Partitions and tablets are one-to-one. When you initiate a partition-level major freeze (storage layer major compaction), note the following:
- You cannot initiate a partition-level major freeze (storage layer major compaction) if the corresponding partition is being processed by a tenant-level major freeze (storage layer major compaction).
- You cannot initiate a partition-level major freeze (storage layer major compaction) if the corresponding partition is being processed by an adaptive scheduling major freeze (storage layer major compaction).
- You cannot initiate a partition-level major freeze (storage layer major compaction) if the replicas of the corresponding partition are in an inconsistent state.
- You cannot initiate a partition-level major freeze (storage layer major compaction) if the corresponding partition is being restored or transferred.
- You cannot initiate a partition-level major freeze (storage layer major compaction) if the major freeze (storage layer major compaction) is suspended.
- A partition-level major freeze (storage layer major compaction) is a major freeze (storage layer major compaction) performed on multiple replicas of the same partition. It consumes CPU and disk I/O resources. Before you initiate a partition-level major freeze (storage layer major compaction), you need to evaluate the resource usage of the current tenant. After the partition-level major freeze (storage layer major compaction) is initiated, the CPU and I/O usage will increase.
Examples
Example of major compaction
The sys tenant initiates a major compaction for itself.
obclient> ALTER SYSTEM MAJOR FREEZE;The sys tenant initiates a major compaction for all user tenants except the sys tenant and the Meta tenant.
obclient> ALTER SYSTEM MAJOR FREEZE TENANT = all_user;The sys tenant initiates a major compaction for all Meta tenants.
obclient> ALTER SYSTEM MAJOR FREEZE TENANT = all_meta;The sys tenant initiates a major compaction for the
tenant1andtenant2tenants.obclient> ALTER SYSTEM MAJOR FREEZE TENANT = tenant1,tenant2;
Example of major dump
The sys tenant initiates a major dump for itself.
obclient> ALTER SYSTEM MINOR FREEZE;The sys tenant initiates a major dump for all user tenants except the sys tenant and the Meta tenant.
obclient> ALTER SYSTEM MINOR FREEZE TENANT = all_user;The sys tenant initiates a major dump for all Meta tenants.
obclient> ALTER SYSTEM MINOR FREEZE TENANT = all_meta;The sys tenant initiates a major dump for the
tenant1andtenant2tenants.obclient> ALTER SYSTEM MINOR FREEZE TENANT = tenant1,tenant2;The sys tenant initiates a major dump for a specified partition under the
tenant1tenant.obclient> ALTER SYSTEM MINOR FREEZE tenant = tenant1 tablet_id = 1100611139453887;The sys tenant initiates a major dump for a specified OBServer node.
obclient> ALTER SYSTEM MINOR FREEZE SERVER = ('10.XXX.XXX.XXX:2882');The sys tenant initiates a major dump for a specified log stream under the
tenant1tenant.obclient> ALTER SYSTEM MINOR FREEZE tenant = tenant1 LS 1;The sys tenant initiates a major dump for a specified partition under a specified log stream under the
tenant1tenant.obclient> ALTER SYSTEM MINOR FREEZE tenant = tenant1 ls 1 tablet_id = 60000;
Example of pausing or resuming major compaction
The sys tenant pauses a major compaction for all user tenants except the sys tenant and the Meta tenant.
obclient> ALTER SYSTEM SUSPEND MERGE TENANT = all_user;The sys tenant pauses a major compaction for the
tenant1andtenant2tenants.obclient> ALTER SYSTEM SUSPEND MERGE TENANT = tenant1,tenant2;The sys tenant pauses a major compaction for all Meta tenants.
obclient> ALTER SYSTEM SUSPEND MERGE TENANT = all_meta;The sys tenant resumes a major compaction for all user tenants except the sys tenant and the Meta tenant.
obclient> ALTER SYSTEM RESUME MERGE TENANT = all_user;The sys tenant resumes a major compaction for the
tenant1andtenant2tenants.obclient> ALTER SYSTEM RESUME MERGE TENANT = tenant1,tenant2;The sys tenant resumes a major compaction for all Meta tenants.
obclient> ALTER SYSTEM RESUME MERGE TENANT = all_meta;
Example of clearing the major compaction error flag
The sys tenant clears the major compaction error flag for all user tenants except the sys tenant and the Meta tenant.
obclient> ALTER SYSTEM CLEAR MERGE ERROR TENANT = all_user;The sys tenant clears the major compaction error flag for the
tenant1andtenant2tenants.obclient> ALTER SYSTEM CLEAR MERGE ERROR TENANT = tenant1,tenant2;The sys tenant clears the major compaction error flag for all Meta tenants.
obclient> ALTER SYSTEM CLEAR MERGE ERROR TENANT = all_meta;
Example of initiating a major compaction at the table level
The sys tenant queries the
table_idof the table tbl2 to be compacted.obclient(root@sys)[oceanbase]> SELECT a.tenant_id, b.tenant_name, a.database_name, a.table_id, a.table_name FROM oceanbase.CDB_OB_TABLE_LOCATIONS a, oceanbase.DBA_OB_TENANTS b WHERE a.tenant_id=b.tenant_id AND a.table_name = 'tbl2' AND b.tenant_name = 'mysql001';The query result is as follows:
+-----------+-------------+---------------+----------+------------+ | tenant_id | tenant_name | database_name | table_id | table_name | +-----------+-------------+---------------+----------+------------+ | 1002 | mysql001 | test | 500002 | tbl2 | +-----------+-------------+---------------+----------+------------+ 1 row in setExecute the following statement to initiate a major compaction at the table level.
obclient(root@sys)[oceanbase]> ALTER SYSTEM MAJOR FREEZE TENANT = mysql001 TABLE_ID = 500002;
Example of initiating a major compaction at the partition level
Query the TABLET ID of the table.
Here is an example:
obclient> SELECT a.tenant_id, b.tenant_name, a.database_name, a.table_id, a.table_name, a.tablet_id, a.PARTITION_NAME, a.SUBPARTITION_NAME FROM oceanbase.CDB_OB_TABLE_LOCATIONS a, oceanbase.DBA_OB_TENANTS b WHERE a.tenant_id=b.tenant_id AND a.table_name = 'test_tbl1' AND b.tenant_name = 'oracle001';The query 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 fields, see oceanbase.CDB_OB_TABLE_LOCATIONS.
Initiate a major compaction.
Here is an example:
obclient> ALTER SYSTEM MAJOR FREEZE TENANT = oracle001 TABLET_ID = 200008;
Example of initiating a major dump at the partition level
Query the TABLET ID of the table.
Here is an example:
obclient> 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 query 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 fields, see oceanbase.CDB_OB_TABLE_LOCATIONS.
Initiate a major dump.
Here is an example:
obclient> ALTER SYSTEM MINOR FREEZE TENANT = oracle001 TABLET_ID = 200008;
