欢迎关注“数据库运维之道”公众号,一起学习数据库技术!
本期将为大家分享“调用全文检索contains函数遇到 ora-600 [kdsgrp1]错误”的解决方案。
关键词:ora-600 [kdsgrp1]、ora 600 [kdsgrp1]、contains函数、ctxsys.context索引
客户的业务系统调用某sql语句抛出“ora-600 [kdsgrp1]”错误,这个sql语句的限制条件使用全文检索contains函数。大家都知道使用like写法进行模糊查询无法使用索引,导致sql查询效率下降。但是创建ctxsys.context类型索引,可以大大地提升查询效率。
1、业务表的记录数超过1亿条,调用的sql语句文本如下,即从某个本文字段中匹配出对应身份证号的记录。
select t.col1,t.col2 from tab01 t where contains(t.col3,'身份证号码') > 0;
2、手动调用对应的sql语句可以重现错误,报错截图如下:
3、数据库alert日志文件里产生相应的trace跟踪文件。
ora-00600: internal error code, arguments: [kdsgrp1], [], [], [], [], [], [], [], [], [], [], []
tue feb 20 11:16:59 2024
errors in file /u01/app/oracle/diag/rdbms/ywzd/ywzd2/trace/ywzd2_ora_455424.trc (incident=465338):
ora-00600: internal error code, arguments: [kdsgrp1], [], [], [], [], [], [], [], [], [], [], []
incident details in: /u01/app/oracle/diag/rdbms/ywzd/ywzd2/incident/incdir_465338/ywzd2_ora_455424_i465338.trc
use adrci or support workbench to package the incident.
see note 411.1 at my oracle support for error and packaging details.
1、dba经常会遇到ora-600内部错误,这个错误表示进程遇到意外情况。第一个参数是内部消息编码,此参数和数据库版本号对于确定根本原因起到很关键的作用。此类错误一般是与数据库bug有关。
oerr ora 600
00600, 00000, "internal error code, arguments: [%s], [%s], [%s], [%s], [%s], [%s], [%s], [%s], [%s], [%s], [%s], [%s]"
// *cause: this is the generic internal error number for oracle program
// exceptions. it indicates that a process has encountered a low-level,
// unexpected condition. the first argument is the internal message
// number. this argument and the database version number are critical in
// identifying the root cause and the potential impact to your system.
//
// *action: visit my oracle support to access the ora-00600 lookup tool
// (reference note 600.1) for more information regarding the specific
// ora-00600 error encountered.
2、执行sql语句会经历parse(解析) -> exec(执行) -> fetch(从游标中获取数据) 几个过程。在获取数据阶段,数据库无法找到期望的记录时,会抛出ora-600 [kdsgrp1]错误。其中kdsgrp函数是kernel data seek/scan fetch by rowid get row piece的简称。错误发生在内存中,因此可能是仅内存错误,也可能是磁盘损坏导致的错误。一般情况由下面6种情况导致。
(1)lost writes;(2)parallel dml issues;(3)index corruption;(4)data block corruption;(5)consistent read [cr] issues;(6)buffer cache corruption
3、采用数据库日志管理工具tfactl采集数据库错误前3小时内的日志信息,并结合mos知识库对跟踪文件进行一步排查分析。根据“ current sql statement for this session”标识,查找跟踪文件是否有相关的sql语句。根据“plan table”标识,查找执行计划中调用的索引。通过刷新数据缓存无法解决,然后通过索引分析验证没有损坏情况。
alter system flush buffer_cache;
analyze index <owner>.<index name> validate structure online;
4、根据”not found“标识,查找跟踪文件并能匹配到相关记录,说明确实存在索引与表数据不一致。
----- beginning of customized incident dump(s) -----
kdsdumpstate: cdb: 0 dspdb: 0 type: 1
* kdsgrp1-1: ***********************************************
row 0x50f0422e.5 continuation at: 0x50f0422e.5 file# 323 block# 3162670 slot 5 not found (dscnt: 0)
kdstabn_get: 0 ..... ntab: 1
curslot: 5 ..... nrows: 15
5、根据file#和block#进一步定位数据库对象,查询出来的结果就是sql语句中的业务表。然后通过表分析验证表没有损坏情况。
col segment_name for a30
col owner for a20
col partition_name for a20
col tablespace_name for a20
set linesize 1000
select segment_name,partition_name,segment_type,owner,tablespace_name
from sys.dba_extents
where file_id=&afn
and &bad_block_id between block_id and block_id + blocks-1;
analyze table <owner>.<table name> validate structure cascade online;
6、根据note 285586.1 - ora-600 [kdsgrp1] 匹配是否有相似问题,结论是没有匹配到解决方案。
7、根据oracle text health check (doc id 823649.1)提供的脚本,对特定实例的oracle text组件的总体运行状况进行检查。结论是检查到sys用户下有部分对象编译失效。
8、检查哪些ctxsys对象是否重复创建,检查确实存在重复对象并且删除。
there are many ctxsys objects that are incorrectly created in the sys schema.
set pause off
set heading off
set pagesize 0
set feedback off
set verify off
spool dropsys.sql
select 'drop ' || object_type || ' sys.' || object_name || ';'
from dba_objects
where object_name not in ('aq$_schedules_primary','dbms_repcat_auth','aq$_schedules','product_user_profile','sqlplus_product_profile','product_privs','help','help_topic_seq') and object_name||object_type in
(select object_name||object_type
from dba_objects
where owner = 'sys')
and owner = 'ctxsys';
spool off
exit
结合上述的排查与处置,可以初步推断是数据一致性问题导致(consistent read [cr] issues),即表数据与索引数据不一致,需重建索引。
1、非业务高峰期间,开发单位删除该索引,并重新创建索引。
create index ywzd.idx_publicmatter57441_2f on ywzd.publicmatter57441_2 (zjh)
indextype is ctxsys.context parameters ('sync (on commit)');
2、创建索引后,查看对应的执行计划,cost代价减少至10以内,响应时间秒级以内。
全文索引是一种提高搜索性能的技术,可以显著加快查找包含特定词语的记录的速度。contains函数是oracle数据库中一个非常有用的全文搜索函数,它可以用于查找包含指定词语或表达式的记录,并返回相关性评分。假设我们有一个名为articles的表格,其中有一个名为content的clob列,存储了文章的内容。我们想要查找包含特定词语的记录,可以使用如下语句:
这个查询将返回articles表中所有包含oracle词语的记录。
select *
from articles
where contains(content, 'oracle');
1、causes and solutions for ora-600 [kdsgrp1] (doc id 1332252.1)
2、ora-600 [kdsgrp1] (doc id 285586.1)
3、oracle text health check (doc id 823649.1)
以上就是本期关于“调用全文检索contains函数遇到 ora-600 [kdsgrp1]错误”案例分享。希望能给大家带来帮助!
欢迎关注“数据库运维之道”公众号,一起学习数据库技术!
发表评论