暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

【问题诊断】调用全文检索CONTAINS函数遇到 ora-600 [kdsgrp1]错误

186
本期将为大家分享“调用全文检索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_COL3 on ywzd.TAB01(COL3)
                  indextype is CTXSYS.CONTEXT;
                  2、创建索引后,查看对应的执行计划,cost代价减少至10以内,响应时间在1秒以内。

                  CONTAINS函数介绍

                  全文索引是一种提高搜索性能的技术,可以显著加快查找包含特定词语的记录的速度。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)

                    4、https://www.modb.pro/oraFunc

                    以上就是本期关于“调用全文检索CONTAINS函数遇到 ora-600 [kdsgrp1]错误”的解决方案。希望能给大家带来帮助。

                    欢迎关注“数据库运维之道”公众号,一起学习数据库技术。

                    欢迎加我的微信,拉你进数据库微信群。

                    推荐阅读

                    【干货攻略】ORA-6544 [pevm_peruws_callback-1] [1000] 超过最大打开游标数问题

                    【干货攻略】Oracle报错篇 ORA-01378 磁盘扇区大小不兼容问题

                    文章转载自数据库运维之道,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

                    评论