【OceanBase诊断调优 】—— 建索引执行报错问题排查

背景

建索引可能因各种各样的原因产生报错,本文主要介绍碰到建索引报错时,如何定位到建索引报错的日志,方便后续进一步使用工具一键收集日志/根因分析,分析根本原因。

备注:此文档中涉及的语句适用于版本号>=4.2.3和 >= 4.3的。

问题排查

建索引主要分为几个阶段

  1. 发送RPC给RS执行建索引的第一步schema变更,并生成调度任务
  2. RS按照状态机执行调度任务,具体分为如下步骤
    1. 等事务结束
    2. 数据补全
    3. 校验checksum
    4. 索引表生效
    5. 失败/成功清理
  1. 建索引的工作线程刷新到RS执行任务完成,返回结果

建索引报错的日志分析的基本思路是根据建索引的基本步骤,判断建索引失败在哪一步,然后决策收集哪些机器的日志,排查的基本步骤如下

  1. 获取DDL报错表格的名字和租户的名字,可以作为输入参数
  2. 根据表格名字和租户名字,获取table_id,tenant_id
select tenant_id from __all_tenant where tenant_name = '租户名';
select table_id from __all_virtual_table where table_name = '表名' and tenant_id = '租户id';
  1. 根据索引名,查询到索引表ID
1. 根据索引名,查询索引表的id
select table_id from __all_virtual_table_history where tenant_id = 'xxx' and data_table_id = 'xxx' and table_name like '%索引名%';
  1. 根据索引表ID,查询__all_virtual_ddl_error_message表格中是否有记录(select task_id from __all_virtual_ddl_error_message where tenant_id = 'xxxx' and object_id = 'xxxx'),如果无记录,那说明失败在发送RPC,打印出信息,提示此时需要人工接入排查(这里后续梳理出需要添加的信息方便排查问题),否则进入步骤5
  2. 根据__all_virtual_ddl_error_message中查询到的task_id字段,查询__all_rootservice_event_history表(select event, trace_id,value6,rs_svr_ip, rs_svr_port from __all_rootservice_event_history where tenant_id = xxxx and value4 = 'task_id' and value2 != 0 and event != 'switch_state' and event not like 'index build task process fail' order by gmt_create desc limit 1;),根据失败所在的步骤,决策收集的信息,如果event字段的值为是ddl wait trans end ctx try_wait,那么进入步骤6,如果是 index sstable build task finish,那么进入步骤7,如果是其他的步骤,那么进入步骤8
  3. 如果是在等事务结束阶段失败,也就是event的名字为ddl wait trans end ctx try_wait,那么根据trace_id,去捞主表所有的tablet所在leader节点的日志
  4. 如果是在补数据阶段失败,那么根据value6字段解析出补数据失败的observer地址,根据observer地址以及trace_id,捞取observer对应的日志
  5. 如果是其他阶段失败,那么根据trace_id,以及rs_svr_ip和rs_svr_port来捞取执行时主RS的日志

OceanBase敏捷诊断工具相关链接:

github仓库 GitHub - oceanbase/oceanbase-diagnostic-tool: OceanBase Diagnostic Tool is designed to help OceanBase users quickly gather necessary information and analyze the cause of the problem.
rpm包下载 OceanBase分布式数据库-海量数据 笔笔算数
文档链接 OceanBase分布式数据库-海量数据 笔笔算数

最近更新

  1. TCP协议是安全的吗?

    2024-04-21 06:08:04       16 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-04-21 06:08:04       16 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-04-21 06:08:04       15 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-04-21 06:08:04       18 阅读

热门阅读

  1. PostgreSQL 窗口函数汇总

    2024-04-21 06:08:04       15 阅读
  2. 个人练习之-jenkins

    2024-04-21 06:08:04       15 阅读
  3. MyBatis可以如何实现分页查询?

    2024-04-21 06:08:04       15 阅读
  4. Swift中协程与异步编程

    2024-04-21 06:08:04       18 阅读
  5. c++补充

    c++补充

    2024-04-21 06:08:04      17 阅读
  6. clang:C++ 编程入门

    2024-04-21 06:08:04       24 阅读
  7. iOS 知识点---闭包

    2024-04-21 06:08:04       11 阅读
  8. Swift中枚举的高级用法

    2024-04-21 06:08:04       19 阅读
  9. Spark面试整理-Spark集成HBase

    2024-04-21 06:08:04       19 阅读
  10. ARM GPIO模拟IIC获取温湿度

    2024-04-21 06:08:04       18 阅读