After you initiate a major compaction, you can view the compaction progress and other information by querying internal tables or on OceanBase Cloud Platform (OCP).
View the compaction information by querying internal tables
You can view the compaction process by querying internal tables. Generally, the time required for a major compaction depends on the amount of data changed since the last major compaction. The time required by the major compaction increases as the amount of data changed since the last compaction increases. The time required by the major compaction is also subject to the number of threads for the compaction, the cluster load during the compaction, and whether rotating major compaction is enabled.
You can run the following statement to check the compaction progress:
obclient> SELECT * FROM __all_zone WHERE name LIKE '%merge%';
| Parameter | Description |
|---|---|
| is_merge_error | Indicates whether an error occurred during the major compaction. |
| last_merged_version | The last major compaction version of all zones in the cluster. |
| merge_status | The status of the major compaction, which can be IDLE, ERROR, TIMEOUT, or MERGING. |
| all_merged_version | All major compaction versions of all zones in the cluster. |
| is_merge_timeout | Indicates whether the major compaction has timed out. |
| last_merged_time | The time of the last major compaction. |
| last_merged_version | The version of the last major compaction. |
| merge_start_time | The time when the major compaction of the zone started. |
If the major compaction takes a long time and the volume of the incremental data since the last compaction is large, you can use the following statement to check the compaction progress by querying an internal table:
obclient> SELECT * FROM __all_virtual_partition_sstable_image_info;
| Field | Type | NULL | Description |
|---|---|---|---|
| zone | varchar(256) | NO | The zone name. |
| svr_ip | varchar(32) | NO | The IP address. |
| svr_port | bigint(20) | NO | The port number. |
| major_version | bigint(20) | NO | The major compaction version. |
| min_version | bigint(20) | NO | The minor compaction version. |
| ss_store_count | bigint(20) | NO | The total number of SSStores. |
| merged_ss_store_count | bigint(20) | NO | The total number of SSStores compacted. |
| modified_ss_store_count | bigint(20) | NO | The total number of SSStores modified. |
| macro_block_count | bigint(20) | NO | The total number of macroblocks. |
| use_old_macro_block_count | bigint(20) | NO | The number of macroblocks reused. |
| merge_start_time | timestamp(6) | NO | The time when the major compaction started. |
| merge_finish_time | timestamp(6) | NO | The time when the major compaction completed. |
| merge_process | bigint(20) | NO | The progress of the major compaction. |
| rewrite_macro_old_micro_block_count | bigint(20) | NO | The number of microblocks reused. |
| rewrite_macro_total_micro_block_count | bigint(20) | NO | The number of microblocks written, |
In addition to querying the internal tables, you can also check the partition-level major compaction progress by querying the logs for the compaction start and success records of each partition:
egrep "begin to merge partition|succ to merge partition" observer.log
You can query the __all_virtual_partition_sstable_image_info table for the macroblock-level major compaction progress, as well as the partition-level major compaction progress. A macroblock is 2 MB in size, and therefore is at a granule finer than a partition. If a partition is very large during a major compaction, you can check the macro_block_count and use_old_macro_block_count columns in the internal table. If the values in the two columns are constantly changing, the major compaction is still in progress.