首批通过分布式安全可靠测评,为关键业务系统打造
异步批量 location_cache 刷新任务不执行
更新时间:2026-07-24 10:01
问题现象
当发生 __all_core_table/__all_root_table 的 Leader 切主时,有概率会导致 __all_core_table/__all_root_table 的异步 location_cache 刷新任务不调度。此时,SQL 触发异步的 location_cache 刷新任务会因为 __all_core_table/__all_root_table 的 Leader 不准而持续失败,从而导致 SQL 执行超时。
关键诊断信息
触发条件
发生 __all_core_table/__all_root_table 的 Leader 切主时。
问题原因
从 OceanBase 数据库 V2.2.6 版本之后,location_cache 异步刷新进行了批量化改造以减少 location_cache 刷新的消耗和提高 location 的实时性。批量异步 location_cache 刷新依赖的一个基础队列结构在某些场景下会出现饿死的行为,会导致了 __all_core_table/__all_root_table 的异步刷新任务生成了不执行。
问题的风险及影响
__all_core_table/__all_root_table 切主后有较小的概率触发,但触发了该问题的话在 location_cache 不准的情况下,最坏情况下是持续 2h 无法刷新出来 location_cache。
影响租户
影响 OceanBase 数据库中的 SYS 租户和 Oracle 租户以及 MySQL 租户。
影响的版本
OceanBase 数据库企业版 V2.2.77 GA(oceanbase-2.2.77-20210508211731)及之后版本、V3.1.2 GA(oceanbase-3.1.2-20210618150922)及之后版本、V3.2.3 GA(oceanbase-3.2.3.0-20220418212020)及之后版本、V3.2.4 GA(oceanbase-3.2.4.0-100000072022102819)及之后版本、V4.1.0 GA(oceanbase-4.1.0.0-100001122023040322)及之后版本。
解决方法
升级至问题已修复版本。目前已修复的版本包括 OceanBase 数据库企业版 V2.2.77 BP17(oceanbase-2.2.77-117000112023051914)及之后版本、V3.2.3 BP9(oceanbase-3.2.3.3-109000182023071410)及之后版本、V3.2.4 BP4(oceanbase-3.2.4.4-104000052023062021)及之后版本、V4.1.0 BP1(oceanbase-4.1.0.0-101000052023050621)及之后版本。
以系统租户身份直连到有问题的 OBServer 节点,执行以下查询触发
__all_core_table/__all_root_table的同步 location cache 刷新。select count(*) from oceanbase.__all_virtual_proxy_schema where tenant_name = "sys" and database_name = "oceanbase" and table_name = "__all_core_table" and partition_id = 0; select count(*) from oceanbase.__all_virtual_proxy_schema where tenant_name = "sys" and database_name = "oceanbase" and table_name = "__all_root_table" and partition_id = 0;
规避方法
周期性(比如 10s)以系统租户身份直连到集群所有 OBServer 节点,执行以下查询触发 __all_core_table/__all_root_table 的同步 location cache 刷新。
select count(*) from oceanbase.__all_virtual_proxy_schema where tenant_name = "sys" and database_name = "oceanbase" and table_name = "__all_core_table" and partition_id = 0;
select count(*) from oceanbase.__all_virtual_proxy_schema where tenant_name = "sys" and database_name = "oceanbase" and table_name = "__all_root_table" and partition_id = 0;