首批通过分布式安全可靠测评,为关键业务系统打造
如何确定 Plan Cache 的淘汰机制是否正常
更新时间:2026-05-08 08:11
当 Plan Cache 内存不足时,即出现 plan cache memory used reach limit 告警,我们需要判断当前 Plan Cache 的内存使用状况以及淘汰机制是否正常。
OBServer 会在 Plan Cache 进行淘汰(evict)时记录日志信息到 observer.log 中,我们可以从日志中查看相关信息来判断当前 Plan Cache 的内存使用状况和淘汰机制的运行情况。
示例如下。
使用租户 ID(格式为
tenant_id=1009)和关键字plan cache evict info搜索日志。[2023-09-03 01:41:11.715207] INFO [SQL.PC] ob_plan_cache.cpp:1217 [2972130][732][Y0-0000000000000000] [lt=11] [dc=0] plan cache evict info(tenant_id=1009, mem_hold=19327352832, mem_limit=19327352830, plan_num=113162, pcv_set_num=225067)该日志显示了 Plan Cache 触发淘汰时的内存使用状况
mem_hold=19327352832 > mem_limit=19327352830,即内存用满了。查看紧随其后的日志中包含
actual evict number或EVICT INFO的日志记录。[2023-09-03 01:41:11.800506] INFO [SQL.PC] ob_plan_cache.cpp:1448 [2972130][732][Y0-0000000000000000] [lt=10] [dc=0] actual evict number(evict_value_num=0) [2023-09-03 01:41:12.835802] INFO [SQL.PC] ob_plan_cache.cpp:1448 [2972130][732][Y0-0000000000000000] [lt=17] [dc=0] actual evict number(evict_value_num=112533) [2023-09-03 01:41:13.165922] INFO [SQL.PC] ob_plan_cache.cpp:1230 [2972130][732][Y0-0000000000000000] [lt=29] [dc=0] EVICT INFO(to_evict.count()=112533)actual evict number表示当前淘汰的日志量,如果与 EVICT INFO 中的数量相同,说明淘汰正常进行。注意
由于
actual evict number日志和EVICT INFO并没有 tenant_id 打印,需要注意避免因日志限流导致日志串行或者日志不准确的情况,正常情况下,每一个租户 ID 都应该有这些日志输出,如果缺失,可能存在日志限流导致无法准确判断问题。
适用版本
OceanBase 数据库 V2.x 和 V3.x 版本。