67 Star 603 Fork 109

GVP万里数据库/GreatSQL

explain crash

已验收
缺陷
创建于  
2024-08-20 11:00

【 使用版本 】

8.0.32-26

【 使用环境 】

docker greatsql/greatsql:8.0.32-26

【问题描述】
执行 explain format=tree 时奔溃

【复现路径】

sql:

create database test;
use test;
create table t_nteqpb (
c_i9fo int ,
c_c10 text ,
c_kqm double ,
c_thwrhzi4 double ,
c_au8s_mtqox tinyint ,
c_e71sc1 text ,
c_sqlk_kif tinyint ,
c_a03zk_2mns text ,
c_i10hej int ,
primary key(c_i10hej, c_i9fo),
unique(c_i9fo)
);

create table t_j02n (
c_pa9r int ,
c_xza2f7ep int ,
c_nj91iy6exb tinyint ,
c_x8r tinyint ,
c_t int ,
primary key(c_pa9r, c_t),
unique(c_xza2f7ep)
);
create table t_txmfavwl2m (
c_d int ,
c_s68jkemsq text ,
c_jm1cxnl double,
primary key(c_d),
unique(c_d)
);
create table t_r as
select
    ref_0.c_d as c0,
    ref_0.c_jm1cxnl as c1,
    ref_0.c_s68jkemsq as c2,
    ref_0.c_d as c3
  from
    t_txmfavwl2m as ref_0
  where 0<>0;

explain format=tree 
select  
    ref_1.c2 as c0
  from 
    t_r as ref_1
  where (ref_1.c3 >= ( 
    select  
          (select count(my_row_id) from t_r)
             as c0
        from 
          t_txmfavwl2m as ref_2
        where 0<>0
      union
      (
      select  
          ref_1.c3 as c0
        from 
          t_j02n as ref_3
        where (NOT NOT(cast( (cast(ref_1.c1 as double) != cast(ref_1.c1 as double)) as unsigned)))
      )
      order by c0 limit 1))
;

crash 堆栈:

Thread 51 "connection" received signal SIGSEGV, Segmentation fault.
[Switching to LWP 144903]
operator() (__closure=0x7f047d395080, item=0x7ed141a0c278) at /opt/greatsql-8.0.32-26/sql/join_optimizer/explain_access_path.cc:245
245             if (query_block->join->needs_finalize) {
(gdb) p query_block
$1 = (Query_block *) 0x7ed141a062f0
(gdb) p query_block->join
$2 = (JOIN *) 0x0
(gdb) l
240             } else {
241               snprintf(description, sizeof(description),
242                        "Select #%d (subquery in %s; run only once)",
243                        query_block->select_number, source_text);
244             }
245             if (query_block->join->needs_finalize) {
246               subselect->unit->finalize(current_thd);
247             }
248             AccessPath *path;
249             if (subselect->unit->root_access_path() != nullptr) {
(gdb) bt
#0  operator() (__closure=0x7f047d395080, item=0x7ed141a0c278) at /opt/greatsql-8.0.32-26/sql/join_optimizer/explain_access_path.cc:245
#1  0x0000000003ece04f in Item::walk_helper_thunk<GetAccessPathsFromItem(Item*, char const*, std::vector<ExplainChild>*)::<lambda(Item*)> >(uchar *) (this=0x7ed141a0c278, 
    arg=0x7f047d395080 "pQ9}\004\177") at /opt/greatsql-8.0.32-26/sql/item.h:2561
#2  0x00000000035e02a1 in Item_subselect::walk (this=0x7ed141a0c278, processor=
    (bool (Item::*)(Item * const, unsigned char *)) 0x3ece02c <Item::walk_helper_thunk<GetAccessPathsFromItem(Item*, char const*, std::vector<ExplainChild>*)::<lambda(Item*)> >(uchar *)>, walk=enum_walk::POSTFIX, arg=0x7f047d395080 "pQ9}\004\177") at /opt/greatsql-8.0.32-26/sql/item_subselect.cc:662
#3  0x0000000003ece0a0 in WalkItem<GetAccessPathsFromItem(Item*, char const*, std::vector<ExplainChild>*)::<lambda(Item*)> >(Item *, enum_walk, struct {...} &&) (item=0x7ed141a0c278, 
    walk=enum_walk::POSTFIX, functor=...) at /opt/greatsql-8.0.32-26/sql/item.h:3827
#4  0x0000000003ebf7af in GetAccessPathsFromItem (item_arg=0x7ed141a0c278, source_text=0x67074d2 "projection", children=0x7f047d395170)
    at /opt/greatsql-8.0.32-26/sql/join_optimizer/explain_access_path.cc:223
#5  0x0000000003ebf849 in GetAccessPathsFromSelectList (join=0x7ed141af59c0, children=0x7f047d395170) at /opt/greatsql-8.0.32-26/sql/join_optimizer/explain_access_path.cc:282
#6  0x0000000003ecb96b in ExplainAccessPath (path=0x7ed141b23728, materialized_path=0x0, join=0x7ed141af59c0, is_root_of_join=true, input_obj=0x7ed14198be80)
    at /opt/greatsql-8.0.32-26/sql/join_optimizer/explain_access_path.cc:1858
#7  0x0000000003ec2047 in AddChildrenToObject (obj=0x7ed14198bee0, children=..., parent_join=0x7ed141aef950, parent_is_root_of_join=false, alias=...)
    at /opt/greatsql-8.0.32-26/sql/join_optimizer/explain_access_path.cc:733
#8  0x0000000003ecb8ed in ExplainAccessPath (path=0x7ed141af5670, materialized_path=0x0, join=0x7ed141aef950, is_root_of_join=false, input_obj=0x0)
    at /opt/greatsql-8.0.32-26/sql/join_optimizer/explain_access_path.cc:1849
#9  0x0000000003ec2047 in AddChildrenToObject (obj=0x7ed14198b400, children=..., parent_join=0x7ed141aef950, parent_is_root_of_join=false, alias=...)
    at /opt/greatsql-8.0.32-26/sql/join_optimizer/explain_access_path.cc:733
#10 0x0000000003ecb8ed in ExplainAccessPath (path=0x7ed141af57a0, materialized_path=0x0, join=0x7ed141aef950, is_root_of_join=false, input_obj=0x0)
    at /opt/greatsql-8.0.32-26/sql/join_optimizer/explain_access_path.cc:1849
#11 0x0000000003ec2047 in AddChildrenToObject (obj=0x7ed14198bbe0, children=..., parent_join=0x7ed141aef950, parent_is_root_of_join=false, alias=...)
    at /opt/greatsql-8.0.32-26/sql/join_optimizer/explain_access_path.cc:733
#12 0x0000000003ecb8ed in ExplainAccessPath (path=0x7ed141af5838, materialized_path=0x0, join=0x7ed141aef950, is_root_of_join=false, input_obj=0x0)
    at /opt/greatsql-8.0.32-26/sql/join_optimizer/explain_access_path.cc:1849
#13 0x0000000003ec2047 in AddChildrenToObject (obj=0x7ed14198bfa0, children=..., parent_join=0x7ed141aef950, parent_is_root_of_join=false, alias=...)
    at /opt/greatsql-8.0.32-26/sql/join_optimizer/explain_access_path.cc:733
#14 0x0000000003ecb8ed in ExplainAccessPath (path=0x7ed141af5928, materialized_path=0x0, join=0x7ed141aef950, is_root_of_join=true, input_obj=0x0)
    at /opt/greatsql-8.0.32-26/sql/join_optimizer/explain_access_path.cc:1849
#15 0x0000000003ec22c0 in ExplainQueryPlan (path=0x7ed141af5928, query_plan=0x7ed141c0d808, join=0x7ed141aef950, is_root_of_join=true)
    at /opt/greatsql-8.0.32-26/sql/join_optimizer/explain_access_path.cc:754
#16 0x0000000003ecbc69 in PrintQueryPlan[abi:cxx11](THD*, THD const*, Query_expression*) (ethd=0x7ed141c0bbc0, query_thd=0x7ed141c0bbc0, unit=0x7ed141c449a0)
    at /opt/greatsql-8.0.32-26/sql/join_optimizer/explain_access_path.cc:1887
#17 0x0000000003f3b6be in ExplainIterator (ethd=0x7ed141c0bbc0, query_thd=0x7ed141c0bbc0, unit=0x7ed141c449a0) at /opt/greatsql-8.0.32-26/sql/opt_explain.cc:2205
#18 0x0000000003f3bc96 in explain_query (explain_thd=0x7ed141c0bbc0, query_thd=0x7ed141c0bbc0, unit=0x7ed141c449a0) at /opt/greatsql-8.0.32-26/sql/opt_explain.cc:2359
#19 0x0000000003a75dd2 in Sql_cmd_dml::execute_inner (this=0x7ed141a79c98, thd=0x7ed141c0bbc0) at /opt/greatsql-8.0.32-26/sql/sql_select.cc:849
#20 0x0000000003a75119 in Sql_cmd_dml::execute (this=0x7ed141a79c98, thd=0x7ed141c0bbc0) at /opt/greatsql-8.0.32-26/sql/sql_select.cc:605
#21 0x00000000039e4978 in mysql_execute_command (thd=0x7ed141c0bbc0, first_level=true) at /opt/greatsql-8.0.32-26/sql/sql_parse.cc:5140
#22 0x00000000039e6d73 in dispatch_sql_command (thd=0x7ed141c0bbc0, parser_state=0x7f047d397ea0, update_userstat=false) at /opt/greatsql-8.0.32-26/sql/sql_parse.cc:5809
#23 0x00000000039dbe88 in dispatch_command (thd=0x7ed141c0bbc0, com_data=0x7f047d399210, command=COM_QUERY) at /opt/greatsql-8.0.32-26/sql/sql_parse.cc:2222
#24 0x00000000039d9de6 in do_command (thd=0x7ed141c0bbc0) at /opt/greatsql-8.0.32-26/sql/sql_parse.cc:1594
#25 0x0000000003c519a7 in handle_connection (arg=0x7f07641c6c10) at /opt/greatsql-8.0.32-26/sql/conn_handler/connection_handler_per_thread.cc:323
#26 0x0000000005730c14 in pfs_spawn_thread (arg=0x7f077bc54120) at /opt/greatsql-8.0.32-26/storage/perfschema/pfs.cc:2988
#27 0x00007f077e0aa1da in start_thread () from target:/lib64/libpthread.so.0
#28 0x00007f077c43b8d3 in clone () from target:/lib64/libc.so.6

【问题现象及影响】

数据库异常退出

评论 (4)

007 创建了缺陷 10个月前
KAiTO-KAITOO KAiTO 成员 10个月前

应该是一个空指针,query_block->join 的值为 NULL
在单机版中

  • 直接执行该SQL (my_row_id 字段没有,改为 *) 运行正常。
  • explain 执行该SQL (my_row_id 字段没有,改为 *) 运行正常。
  • explain format=tree 和 explain analyze 异常退出

在 Docker 镜像中和单机版本保持一致。感谢您的反馈,会将这个bug反馈给研发同学

KAiTO 任务状态待确认 修改为已确认 10个月前
8779455 greatsql 1615290631 GreatSQL 拥有者 10个月前

谢谢报告,我用MySQL 8.0.33版本测试,也会发生core问题,看起来应该是上游MySQL导致的。

上游是 percona 吧,8.0.33-25崩溃, 8.0.34-26正常

8779455 greatsql 1615290631 GreatSQL 拥有者 3个月前

预计3月10日发布GreatSQL 8.0.32-27新版本,会修复该问题,先关闭,后续如果再有其他新问题再重新提交issue哈。
再次感谢您对GreatSQL的支持。

GreatSQL 任务状态已确认 修改为已验收 3个月前

登录 后才可以发表评论

状态
负责人
项目
Pull Requests
关联的 Pull Requests 被合并后可能会关闭此 issue
预计工期 (小时)
开始日期   -   截止日期
-
置顶选项
优先级
里程碑
分支
参与者(3)
KAiTO-KAITOO 8779455 greatsql 1615290631 007-007gzs
C++
1
https://gitee.com/GreatSQL/GreatSQL.git
git@gitee.com:GreatSQL/GreatSQL.git
GreatSQL
GreatSQL
GreatSQL

搜索帮助