18C 也不能避免 SQL 解析的 Bug
1
概述
在 Oracle 12.2 版本和新发布的18.0版本中存在一个 SQL 解析的 bug,导致了数据库后台报 ora-07445 或者 ora-00600 错误。报 ora-07445 时,可导致数据库断开当前会话连接,无法进行 SQL 操作,当报 ora-00600 时,会话没有断开,但无法完成解析返回结果。
该 bug 的发现敬请参考:http://www.hellodba.com/reader.php?ID=221&lang=CN
2
触发 Bug 的现象
3
Bug 重现测试
读者可以按照以下的语句,可以在 Oracle 12.2 和18.0的版本中测试,重现这个 SQL 解析的 bug,观察报错情况。重现这个 bug 重点符合以下条件:
表中有一个运行为空的字段;
该字段的统计信息被收集过;
该字段中存在空值和非空值。
3.1 创建测试表并插入测试数据
create table tt1 (c1 number, c2 date);
insert into tt1 values(1, sysdate);
insert into tt1 values(1, null);
commit;
3.2 收集表的统计信息
exec dbms_stats.gather_table_stats('SYS', 'TT1', METHOD_OPT=>'for all columns');
3.3 尝试解析以下语句
explain plan for
with
ut as (select c1
from tt1
where nvl (c2 ,
trunc (sysdate ) ) >= trunc (sysdate ) ),
txo as (select distinct c1
from ut , dual),
u as (select * from ut)
select * from u , txo ;
读者可以按照这个测试过程,在自己的测试环境重现 ora-07445 报错,记住,决不能在生产环境的 12.2 的库上测试。
4
报错的信息追踪和影响
[[email protected] ~]$ oerr ora 07445
07445, 00000, "exception encountered: core dump [%s] [%s] [%s] [%s] [%s] [%s]"
// *Cause: An operating system exception occurred which should result in the
// creation of a core file. This is an internal error.
通过服务器上看这个 ora-07445 为核心存储内部的错误。
4.1 后台日志报错
4.2 使用 adrci 工具分析
1> show incident 查看报错信息摘要:
adrci> show incident
2> 查看比较接近的一个 incident_id 的摘要详情:
adrci> show incident -mode detail -p "incident_id=155499"
4.3 语句的执行计划
这个执行计划是从 Oracle 12.1.0.2 版本中取得的,只作为参考。测试数据为根据上述条件创建的。
with
sal as (select empno,name,salary from mytest
where nvl(signdate,trunc (sysdate ) ) >= trunc (sysdate ) ),
inc as (select distinct salary from sal,dual),
mark as (select empno,name from sal)
select * from inc,mark;
Oracle 12.1中基于成本模式的 SQL 执行计划:
4.4 Oracle 官网对报错号的描写
通过 Oracle 官网文档 ORA-600/ORA-7445/ORA-700 Error Look-up Tool (Doc ID 153788.1)查看报错号对应的 bug 信息,发现官网未对 oracle 12.2 或者 18.0 这个 SQL 解析的 bug 作发布,如下:
ORA-07445: exception encountered: core dump [__intel_ssse3_rep_memcpy()+8260] in oracle 12.2.0.1
An Error document for ORA-7445 [type:] is not registered with the tool.
Your request for information on this error has been recorded and will be used for publishing prioritization.
Things to try:
Check the error message and confirm that this is an ORA-7445 error and not an ORA-600 or ORA-700 error.
Use 'Do a general Search for Knowledge' to begin a search for any published documents and bugs that mention the error.
由于这个 ora-07445 报错出现在之前的多个版本的不同场景,以下为12.1版本中有类似的 bug 可以参考一下:
Bug 18463985 - ORA-7445 [__intel_ssse3_rep_memcpy()+8912] for stmt with adaptive plans and cfb (Doc ID 18463985.8)
以及官网文档:
Bug 21856417 - Wrong Result: null values with partial join evaluation , Filter Push Down and fix for bug 18463985 (Doc ID 21856417.8)