OceanBase 数据库如何查看合并状态及当期合并进度

本文介绍如何查看合并的状态、进度和磁盘使用量,以及如何触发、加速/放慢合并,排查合并问题。

如何查看合并状态?

通过以下 SQL 查询

__ALL_ZONE

表,查看

INFO

列为

IDLE

对应行的

gmt_modified

列值,该值表示最近一次合并的完成时间。

obclient> SELECT * FROM __ALL_ZONE WHERE INFO LIKE ‘%IDLE%’; ±---------------------------±---------------------------±------±-------------±------±-----+ | gmt_create | gmt_modified | zone | name | value | info | ±---------------------------±---------------------------±------±-------------±------±-----+ | 2021-03-24 10:33:04.727508 | 2021-03-31 02:01:41.263266 | | merge_status | 0 | IDLE | | 2021-03-24 10:33:04.729196 | 2021-03-31 02:01:31.046593 | zone1 | merge_status | 0 | IDLE | | 2021-03-24 10:33:04.730523 | 2021-03-31 02:00:50.346948 | zone2 | merge_status | 0 | IDLE | | 2021-03-24 10:33:04.731953 | 2021-03-31 02:00:50.349732 | zone3 | merge_status | 0 | IDLE | ±---------------------------±---------------------------±------±-------------±------±-----+

如何查看当前的合并进度?

通过以下 SQL 查询

__ALL_VIRTUAL_PARTITION_SSTABLE_IMAGE_INFO

表,其中

merge_process

列表示当前合并进度的百分比。

obclient> SELECT zone,svr_ip,major_version,macro_block_count,use_old_macro_block_count,merge_start_time,merge_finish_time,merge_process,( merge_finish_time - merge_start_time ) AS cost_time, ( macro_block_count - use_old_macro_block_count ) AS merge_macro_block_count,( macro_block_count - use_old_macro_block_count ) / ( merge_finish_time - merge_start_time ) AS avg_per_sec FROM __all_virtual_partition_sstable_image_info ORDER BY zone,svr_ip,major_version; ±------±---------------±--------------±------------------±--------------------------±---------------------------±---------------------------±--------------±----------±------------------------±------------+ | zone | svr_ip | major_version | macro_block_count | use_old_macro_block_count | merge_start_time | merge_finish_time | merge_process | cost_time | merge_macro_block_count | avg_per_sec | ±------±---------------±--------------±------------------±--------------------------±---------------------------±---------------------------±--------------±----------±------------------------±------------+ | zone1 | xxx.xx.xxx.xxx | 8 | 146 | 94 | 2021-03-30 02:01:06.119189 | 2021-03-30 02:01:21.865568 | 100 | 15.746379 | 52 | 3.3023 | | zone1 | xxx.xx.xxx.xxx | 9 | 147 | 99 | 2021-03-31 02:01:03.045246 | 2021-03-31 02:01:20.423085 | 100 | 17.377839 | 48 | 2.7621 | | zone2 | xxx.xx.xxx.xxx | 8 | 146 | 94 | 2021-03-30 02:00:23.553706 | 2021-03-30 02:00:41.144529 | 100 | 17.590823 | 52 | 2.9561 | | zone2 | xxx.xx.xxx.xxx | 9 | 147 | 99 | 2021-03-31 02:00:23.093945 | 2021-03-31 02:00:39.786023 | 100 | 16.692078 | 48 | 2.8756 | | zone3 | xxx.xx.xxx.xxx | 8 | 104 | 74 | 2021-03-30 02:00:22.324217 | 2021-03-30 02:00:39.397535 | 100 | 17.073318 | 30 | 1.7571 | | zone3 | xxx.xx.xxx.xxx | 9 | 104 | 73 | 2021-03-31 02:00:23.667267 | 2021-03-31 02:00:39.314353 | 100 | 15.647086 | 31 | 1.9812 | ±------±---------------±--------------±------------------±--------------------------±---------------------------±---------------------------±--------------±----------±------------------------±------------+ 6 rows in set (0.07 sec)