stoneatom / stonedb

StoneDB is an Open-Source MySQL HTAP and MySQL-Native DataBase for OLTP, Real-Time Analytics, a counterpart of MySQLHeatWave. (https://stonedb.io)
https://stonedb.io/
GNU General Public License v2.0
866 stars 141 forks source link

bug: mysqld crashed due to a failed assertion #1809

Open davidshiz opened 1 year ago

davidshiz commented 1 year ago

Have you read the Contributing Guidelines on issues?

Please confirm if bug report does NOT exists already ?

Describe the problem

Thread 87 "connection" received signal SIGABRT, Aborted.
[Switching to Thread 0x7fd5ac341700 (LWP 196347)]
__GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
50      ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) bt
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1  0x00007fd5d5465859 in __GI_abort () at abort.c:79
#2  0x00007fd5d5465729 in __assert_fail_base (fmt=0x7fd5d55fb588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n",
    assertion=0x561a77d94df0 "send_metadata || field_types == nullptr || field_types[field_pos] == MYSQL_TYPE_LONGLONG",
    file=0x561a77d94190 "/stonedb/sql/protocol_classic.cc", line=3499, function=<optimized out>) at assert.c:92
#3  0x00007fd5d5476fd6 in __GI___assert_fail (
    assertion=0x561a77d94df0 "send_metadata || field_types == nullptr || field_types[field_pos] == MYSQL_TYPE_LONGLONG",
    file=0x561a77d94190 "/stonedb/sql/protocol_classic.cc", line=3499,
    function=0x561a77d94da8 "virtual bool Protocol_text::store_longlong(longlong, bool, uint32)") at assert.c:101
#4  0x0000561a74fe7723 in Protocol_text::store_longlong (this=0x7fcc98005040, from=2, unsigned_flag=false, zerofill=0)
    at /stonedb/sql/protocol_classic.cc:3499
#5  0x0000561a74ae1b72 in Protocol::store_longlong (this=0x7fcc98005040, from=2, unsigned_flag=false)
    at /stonedb/sql/protocol.h:143
#6  0x0000561a74d73d41 in Item::send (this=0x7fcc98098180, protocol=0x7fcc98005040, buffer=0x7fd5ac33b1c0)
    at /stonedb/sql/item.cc:7286
#7  0x0000561a74825290 in THD::send_result_set_row (this=0x7fcc98001040, row_items=...) at /stonedb/sql/sql_class.cc:2865
#8  0x0000561a74fe9d2b in Query_result_send::send_data (this=0x7fcc98097430, thd=0x7fcc98001040, items=...)
    at /stonedb/sql/query_result.cc:100
#9  0x0000561a76c40230 in Tianmu::core::ResultSender::SendRecord (this=0x7fcc98994470,
    r=std::vector of length 3, capacity 4 = {...}) at /stonedb/storage/tianmu/core/engine_results.cpp:366
#10 0x0000561a76c3f9c7 in Tianmu::core::ResultSender::Send (this=0x7fcc98994470, iter=...)
    at /stonedb/storage/tianmu/core/engine_results.cpp:240
#11 0x0000561a76ecb5f2 in Tianmu::core::AggregationAlgorithm::MultiDimensionalGroupByScan (this=0x7fd5ac33bf40, gbw=...,
    limit=@0x7fd5ac33bb10: 5, offset=@0x7fd5ac33bef8: 0, sender=0x7fcc98994470, limit_less_than_no_groups=false)
    at /stonedb/storage/tianmu/core/aggregation_algorithm.cpp:396
#12 0x0000561a76eca562 in Tianmu::core::AggregationAlgorithm::Aggregate (this=0x7fd5ac33bf40, just_distinct=false,
    limit=@0x7fd5ac33bf00: -1, offset=@0x7fd5ac33bef8: 0, sender=0x7fcc98994470)
    at /stonedb/storage/tianmu/core/aggregation_algorithm.cpp:217
#13 0x0000561a76cee637 in Tianmu::core::TempTable::Materialize (this=0x7fcc989978d0, in_subq=false, sender=0x7fcc98994470,
    lazy=false) at /stonedb/storage/tianmu/core/temp_table.cpp:2234
#14 0x0000561a76c0525c in Tianmu::core::Engine::Execute (this=0x561a7d84a4f0, thd=0x7fcc98001040, lex=0x7fcc980043c0,
    result_output=0x7fcc98097430, unit_for_union=0x0) at /stonedb/storage/tianmu/core/engine.cpp:2436
#15 0x0000561a76c0457e in Tianmu::core::Engine::Handle_Query (this=0x561a7d84a4f0, thd=0x7fcc98001040, qe=0x7fcc9800c870,
    result=@0x7fcc98025ec0: 0x7fcc98097430, setup_tables_done_option=0, res=@0x7fd5ac33c620: 0,
    optimize_after_tianmu=@0x7fd5ac33c690: 1, tianmu_free_join=@0x7fd5ac33c624: 1, with_insert=false)
    at /stonedb/storage/tianmu/core/engine.cpp:2281
#16 0x0000561a76b54ce5 in Tianmu::handler::ha_my_tianmu_query (thd=0x7fcc98001040, qe=0x7fcc9800c870,
    result=@0x7fcc98025ec0: 0x7fcc98097430, setup_tables_done_option=0, res=@0x7fd5ac33c620: 0,
--Type <RET> for more, q to quit, c to continue without paging--
    optimize_after_tianmu=@0x7fd5ac33c690: 1, tianmu_free_join=@0x7fd5ac33c624: 1, with_insert=false)
    at /stonedb/storage/tianmu/handler/ha_my_tianmu.cpp:77

#17 0x0000561a7499563b in Sql_cmd_dml::execute (this=0x7fcc98025e98, thd=0x7fcc98001040) at /stonedb/sql/sql_select.cc:579
#18 0x0000561a7490c599 in mysql_execute_command (thd=0x7fcc98001040, first_level=true) at /stonedb/sql/sql_parse.cc:4604
#19 0x0000561a7490e884 in dispatch_sql_command (thd=0x7fcc98001040, parser_state=0x7fd5ac33db90) at /stonedb/sql/sql_parse.cc:5239
#20 0x0000561a74904303 in dispatch_command (thd=0x7fcc98001040, com_data=0x7fd5ac33e4e0, command=COM_QUERY)
    at /stonedb/sql/sql_parse.cc:1959
#21 0x0000561a7490237a in do_command (thd=0x7fcc98001040) at /stonedb/sql/sql_parse.cc:1362

#22 0x0000561a74b3ecb1 in handle_connection (arg=0x561a81e920d0) at /stonedb/sql/conn_handler/connection_handler_per_thread.cc:302
#23 0x0000561a76a60c2c in pfs_spawn_thread (arg=0x561a81eec120) at /stonedb/storage/perfschema/pfs.cc:2942
#24 0x00007fd5d6658609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#25 0x00007fd5d5562133 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Expected behavior

No response

How To Reproduce

create table t1 (libname varchar(21) not null, city text);
create table t3 (isbn varchar(21) not null, libname varchar(21) not null, quantity int);
insert into t3 values('000','New York Public Libra','1');
insert into t3 values('001','New York Public Libra','2');
insert into t3 values('002','New York Public Libra','3');
insert into t3 values('003','New York Public Libra','4');
insert into t3 values('004','New York Public Libra','5');
insert into t3 values('005','New York Public Libra','6');
insert into t3 values('006','San Fransisco Public','5');
insert into t3 values('007','Berkeley Public1','3');
insert into t3 values('007','Berkeley Public2','3');
insert into t3 values('001','NYC Lib','8');
insert into t1 values ('New York Public Libra','New York');
insert into t1 values ('San Fransisco Public','San Fran');
insert into t1 values ('Berkeley Public1','Berkeley');
insert into t1 values ('Berkeley Public2','Berkeley');
insert into t1 values ('NYC Lib','New York');
select
    t1.libname
from
    t3
    left join t1 on t3.libname = t1.libname
group by
    city
having
    count(distinct t1.libname) > 1;

Environment

root@test-stonedb-debugversion80:~# /stonedb/build/install8/bin/mysqld --version
/stonedb/build/install8/bin/mysqld  Ver 8.0.30-debug for Linux on x86_64 (Source distribution)
build information as follow:
        Repository address: https://github.com/stoneatom/stonedb.git:stonedb-8.0-dev
        Branch name: stonedb-8.0-dev
        Last commit ID: d376a14ae
        Last commit time: Date:   Wed May 10 20:31:35 2023 +0800
        Build time: Date: Tue May 16 12:57:45 UTC 2023

Are you interested in submitting a PR to solve the problem?

hustjieke commented 1 year ago

crash happened in 8.0, in 5.7, executing result:

mysql> select
    ->     t1.libname
    -> from
    ->     t3
    ->     left join t1 on t3.libname = t1.libname
    -> group by
    ->     city
    -> having
    ->     count(distinct t1.libname) > 1;
+-----------------------+
| libname               |
+-----------------------+
| New York Public Libra |
| Berkeley Public1      |
+-----------------------+
2 rows in set (0.01 sec)