首批通过分布式安全可靠测评,为关键业务系统打造
修改生成列后查询结果异常
更新时间:2026-05-21 09:16
问题现象
表的分区键是生成列且表上有 unique global 索引,然后用 alter table 等 DDL 语句修改这个生成列,会导致后续走该索引的查询结果异常。
关键诊断信息
触发条件
表的分区键是生成列,且表上有 unique global 索引,且有修改过该列的 DDL 。
事前巡检
以下查询均在 SYS 租户下进行。
找到有问题的索引(OceanBase 数据库的索引预期不能有虚拟生成列,所以这一步就是找到含有虚拟生成列的索引)。
select table_id, database_id, data_table_id, table_name from oceanbase.__all_virtual_table where table_type = 5 and table_id in (select distinct(table_id) from oceanbase.__all_virtual_column where (column_flags & 1) = 1);
其中 data_table_id 是索引的主表 id,可以通过如下查询找到主表
select * from oceanbase.__all_virtual_table where table_id = 主表 id;
理论上,这些索引表都是有问题的,然后如下查询主表的 DDL 历史。
select * from oceanbase.__all_virtual_ddl_operation where table_id = 主表 id and ddl_stmt_str !='';
如果主表修改过分区键,且分区键是虚拟生成列,则确认是该问题。
事后诊断
同 事前巡检 这块内容一样。
问题原因
内核 BUG :修改列时错误更新索引表中列的信息。
问题的风险及影响
走该问题索引的查询结果异常,有正确性问题。
影响租户
影响 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)及之后版本。
解决方法与规避方式
解决方法:
升级至问题已修复版本。目前已修复的版本包括 OceanBase 数据库企业版 V2.2.77 BP19(oceanbase-2.2.77-119000122024060513)及之后版本、V3.1.2 BP11 Hotfix4(oceanbase-3.1.2-111040012024031511)、V3.1.2 BP11 Hotfix5(oceanbase-3.1.2-111050012024062510)、V3.1.2 BP11 Hotfix6(oceanbase-3.1.2-111060012025020814)、V3.1.2 BP11 Hotfix7(oceanbase-3.1.2-111070012025050811)、V3.2.3 BP11(oceanbase-3.2.3.3-111000032024070822)及之后版本、V3.2.4 BP8(oceanbase-3.2.4.8-108000142024041520)及之后版本。
删除该问题索引(含有虚拟生成列的索引)并重建。
规避方式:
无 。