Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: (stonedb) TPCH Q20 crashed #534

Closed
1 task
lujiashun opened this issue Sep 22, 2022 · 8 comments
Closed
1 task

bug: (stonedb) TPCH Q20 crashed #534

lujiashun opened this issue Sep 22, 2022 · 8 comments
Assignees
Labels
A-bug Something isn't working C-stonedb-8.0 associated with stonedb 8.0

Comments

@lujiashun
Copy link

lujiashun commented Sep 22, 2022

Describe the problem

TPCH Q20 crash

#0  __GI_raise (sig=sig@entry6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1  0x00007ffff6db3859 in __GI_abort =6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1  0x00007ffff6db3859 in __GI_abort () at abort.c:79
#2  0x00007ffff6db3729 in __assert_fail_base (fmt=0x7ffff6f49588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n",
    assertion=0x55555c6506d8 "!table || (!table->read_set || bitmap_is_set(table->read_set, field_index()))",
    file=0x55555c650258 "/data/codebase/mysql-server-mysql-8.0.30/sql/field.cc", line=3761, function=<optimized out>) at assert.c:92
#3  0x00007ffff6dc4fd6 in __GI___assert_fail (assertion=0x55555c6506d8 "!table || (!table->read_set || bitmap_is_set(table->read_set, field_index()))",
    file=0x55555c650258 "/data/codebase/mysql-server-mysql-8.0.30/sql/field.cc", line=3761, function=0x55555c651800 "virtual longlong Field_long::val_int() const") at assert.c:101
#4  0x00005555596162a4 in Field_long::val_int (this=0x7ffa84120ae0) at /data/codebase/mysql-server-mysql-8.0.30/sql/field.cc:3761
#5  0x000055555b656cc4 in Tianmu::dbhandler::TianmuHandler::key_convert (this=0x7ffa8411e9e0, key=0x7ffa84169800 "\026\256\027", key_len=4,
    cols=std::vector of length 2, capacity 2 = {...}, keys=std::vector of length 0, capacity 0)
    at /data/codebase/mysql-server-mysql-8.0.30/storage/tianmu/handler/tianmu_handler.cpp:1571
#6  0x000055555b651086 in Tianmu::dbhandler::TianmuHandler::index_read (this=0x7ffa8411e9e0, buf=0x7ffa84120320 "\026\256\027", key=0x7ffa84169800 "\026\256\027", key_len=4,
    find_flag=HA_READ_KEY_EXACT) at /data/codebase/mysql-server-mysql-8.0.30/storage/tianmu/handler/tianmu_handler.cpp:775
#7  0x00005555596741fa in handler::index_read_map (this=0x7ffa8411e9e0, buf=0x7ffa84120320 "\026\256\027", key=0x7ffa84169800 "\026\256\027", keypart_map=1,
    find_flag=HA_READ_KEY_EXACT) at /data/codebase/mysql-server-mysql-8.0.30/sql/handler.h:5289
#8  0x000055555966010a in handler::ha_index_read_map (this=0x7ffa8411e9e0, buf=0x7ffa84120320 "\026\256\027", key=0x7ffa84169800 "\026\256\027", keypart_map=1,
    find_flag=HA_READ_KEY_EXACT) at /data/codebase/mysql-server-mysql-8.0.30/sql/handler.cc:3155
#9  0x0000555559a57e8f in RefIterator<false>::Read (this=0x7ffa8416a0e0) at /data/codebase/mysql-server-mysql-8.0.30/sql/iterators/ref_row_iterators.cc:384
#10 0x0000555559a459d7 in NestedLoopIterator::Read (this=0x7ffa8416a120) at /data/codebase/mysql-server-mysql-8.0.30/sql/iterators/composite_iterators.cc:488
#11 0x00005555593a36b3 in Query_expression::ExecuteIteratorQuery (this=0x7ffa8413c8a0, thd=0x7ffa84001040) at /data/codebase/mysql-server-mysql-8.0.30/sql/sql_union.cc:1290
#12 0x00005555593a3a3c in Query_expression::execute (this=0x7ffa8413c8a0, thd=0x7ffa84001040) at /data/codebase/mysql-server-mysql-8.0.30/sql/sql_union.cc:1343
#13 0x00005555592e7eaa in Sql_cmd_dml::execute_inner (this=0x7ffa84151730, thd=0x7ffa84001040) at /data/codebase/mysql-server-mysql-8.0.30/sql/sql_select.cc:786
#14 0x00005555592e736e in Sql_cmd_dml::execute (this=0x7ffa84151730, thd=0x7ffa84001040) at /data/codebase/mysql-server-mysql-8.0.30/sql/sql_select.cc:586
#15 0x000055555925e287 in mysql_execute_command (thd=0x7ffa84001040, first_level=true) at /data/codebase/mysql-server-mysql-8.0.30/sql/sql_parse.cc:4604
#16 0x0000555559260572 in dispatch_sql_command (thd=0x7ffa84001040, parser_state=0x7fffc848db90) at /data/codebase/mysql-server-mysql-8.0.30/sql/sql_parse.cc:5239
#17 0x0000555559255ff1 in dispatch_command (thd=0x7ffa84001040, com_data=0x7fffc848e4e0, command=COM_QUERY) at /data/codebase/mysql-server-mysql-8.0.30/sql/sql_parse.cc:1959
#18 0x0000555559254068 in do_command (thd=0x7ffa84001040) at /data/codebase/mysql-server-mysql-8.0.30/sql/sql_parse.cc:1362
#19 0x000055555949090f in handle_connection (arg=0x555560f2dcd0) at /data/codebase/mysql-server-mysql-8.0.30/sql/conn_handler/connection_handler_per_thread.cc:302
#20 0x000055555b3b266a in pfs_spawn_thread (arg=0x555563830140) at /data/codebase/mysql-server-mysql-8.0.30/storage/perfschema/pfs.cc:2942
#21 0x00007ffff7fa5609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#22 0x00007ffff6eb0133 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Expected behavior

work well,and show the correct result set.

How To Reproduce

1. create table

CREATE TABLE `partsupp` (
  `PS_PARTKEY` tinyint  NOT NULL,
  `PS_SUPPKEY` int(11) NOT NULL,
  `PS_AVAILQTY` int(11) NOT NULL,
  `PS_SUPPLYCOST` decimal(15,2) NOT NULL,
  `PS_COMMENT` varchar(199) NOT NULL,
  PRIMARY KEY (`PS_PARTKEY`,`PS_SUPPKEY`)
) ENGINE=TIANMU DEFAULT CHARSET=utf8mb4;

CREATE TABLE `lineitem` (
  `L_ORDERKEY` int(11) NOT NULL,
  `L_PARTKEY` tinyint  NOT NULL,
  `L_SUPPKEY` int(11) NOT NULL,
  `L_LINENUMBER` int(11) NOT NULL,
  `L_QUANTITY` decimal(15,2) NOT NULL,
  `L_EXTENDEDPRICE` decimal(15,2) NOT NULL,
  `L_DISCOUNT` decimal(15,2) NOT NULL,
  `L_TAX` decimal(15,2) NOT NULL,
  `L_RETURNFLAG` char(1) NOT NULL,
  `L_LINESTATUS` char(1) NOT NULL,
  `L_SHIPDATE` date NOT NULL,
  `L_COMMITDATE` date NOT NULL,
  `L_RECEIPTDATE` date NOT NULL,
  `L_SHIPINSTRUCT` char(25) NOT NULL,
  `L_SHIPMODE` char(10) NOT NULL,
  `L_COMMENT` varchar(44) NOT NULL,
  PRIMARY KEY (`L_ORDERKEY`,`L_LINENUMBER`)
) ENGINE=TIANMU DEFAULT CHARSET=utf8mb4;

2. insert data

INSERT INTO `lineitem` (`L_ORDERKEY`, `L_PARTKEY`, `L_SUPPKEY`, `L_LINENUMBER`, `L_QUANTITY`, `L_EXTENDEDPRICE`, `L_DISCOUNT`, `L_TAX`, `L_RETURNFLAG`, `L_LINESTATUS`, `L_SHIPDATE`, `L_COMMITDATE`, `L_RECEIPTDATE`, `L_SHIPINSTRUCT`, `L_SHIPMODE`, `L_COMMENT`)
VALUES
	(1, 2, 76910, 1, 17.00, 33078.94, 0.04, 0.02, 'N', 'O', '1996-03-13', '1996-02-12', '1996-03-22', 'DELIVER IN PERSON', 'TRUCK', 'egular courts above the'),
	(1, 3, 73092, 2, 36.00, 38306.16, 0.09, 0.06, 'N', 'O', '1996-04-12', '1996-02-28', '1996-04-20', 'TAKE BACK RETURN', 'MAIL', 'ly final dependencies: slyly bold '),
	(1, 4, 36999, 3, 8.00, 15479.68, 0.10, 0.02, 'N', 'O', '1996-01-29', '1996-03-05', '1996-01-31', 'TAKE BACK RETURN', 'REG AIR', 'riously. regular, express dep'),
	(1, 5, 46316, 4, 28.00, 34616.68, 0.09, 0.06, 'N', 'O', '1996-04-21', '1996-03-30', '1996-05-16', 'NONE', 'AIR', 'lites. fluffily even de'),
	(1, 6, 15274, 5, 24.00, 28974.00, 0.10, 0.04, 'N', 'O', '1996-03-30', '1996-03-14', '1996-04-01', 'NONE', 'FOB', ' pending foxes. slyly re');

INSERT INTO `partsupp` (`PS_PARTKEY`, `PS_SUPPKEY`, `PS_AVAILQTY`, `PS_SUPPLYCOST`, `PS_COMMENT`)
VALUES
	(1, 2, 3325, 771.64, ', even theodolites. regular, final theodolites eat after the carefully pending foxes. furiously regular deposits sleep slyly. carefully bold realms above the ironic dependencies haggle careful'),
	(1, 3, 8076, 993.49, 'ven ideas. quickly even packages print. pending multipliers must have to are fluff'),
	(1, 4, 3956, 337.09, 'after the fluffily ironic deposits? blithely special dependencies integrate furiously even excuses. blithely silent theodolites could have to haggle pending, express requests; fu'),
	(1, 5, 4069, 357.84, 'al, regular dependencies serve carefully after the quickly final pinto beans. furiously even deposits sleep quickly final, silent pinto beans. fluffily reg'),
	(2, 6, 8895, 378.49, 'nic accounts. final accounts sleep furiously about the ironic, bold packages. regular, regular accounts');

3. exexute the sql( subquery of Q20)

select l_quantity from partsupp,lineitem where ps_partkey = l_partkey;

Environment

  1. Linux(UBUNTU20.04/CENTOS7)
  2. stonedb8.0

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

  • Yes, I will!
@lujiashun lujiashun added the A-bug Something isn't working label Sep 22, 2022
@andyli029 andyli029 added the C-stonedb-8.0 associated with stonedb 8.0 label Sep 22, 2022
@andyli029 andyli029 added this to the stonedb_8.0_v1.0.0 milestone Sep 22, 2022
@andyli029
Copy link
Contributor

ACK.

@lujiashun
Copy link
Author

the simplified sql will cause crash :select PS_AVAILQTY from partsupp where ps_partkey =1;

#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1  0x00007efc568ee859 in __GI_abort () at abort.c:79
#2  0x00007efc568ee729 in __assert_fail_base (fmt=0x7efc56a84588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n",
    assertion=0x556716d3b6d8 "!table || (!table->read_set || bitmap_is_set(table->read_set, field_index()))",
    file=0x556716d3b258 "/data/codebase/mysql-server-mysql-8.0.30/sql/field.cc", line=3761, function=<optimized out>) at assert.c:92
#3  0x00007efc568fffd6 in __GI___assert_fail (
    assertion=0x556716d3b6d8 "!table || (!table->read_set || bitmap_is_set(table->read_set, field_index()))",
    file=0x556716d3b258 "/data/codebase/mysql-server-mysql-8.0.30/sql/field.cc", line=3761,
    function=0x556716d3c800 "virtual longlong Field_long::val_int() const") at assert.c:101
#4  0x0000556713d012a4 in Field_long::val_int (this=0x7ef6f40b55e0) at /data/codebase/mysql-server-mysql-8.0.30/sql/field.cc:3761
#5  0x0000556715d41cc4 in Tianmu::dbhandler::TianmuHandler::key_convert (this=0x7ef6f40b3b90, key=0x7ef6f40a58d0 "\001", key_len=4,
    cols=std::vector of length 2, capacity 2 = {...}, keys=std::vector of length 0, capacity 0)
    at /data/codebase/mysql-server-mysql-8.0.30/storage/tianmu/handler/tianmu_handler.cpp:1571
#6  0x0000556715d3c086 in Tianmu::dbhandler::TianmuHandler::index_read (this=0x7ef6f40b3b90, buf=0x7ef6f409f330 "\001",
    key=0x7ef6f40a58d0 "\001", key_len=4, find_flag=HA_READ_KEY_EXACT)
    at /data/codebase/mysql-server-mysql-8.0.30/storage/tianmu/handler/tianmu_handler.cpp:775
#7  0x0000556713d5f1fa in handler::index_read_map (this=0x7ef6f40b3b90, buf=0x7ef6f409f330 "\001", key=0x7ef6f40a58d0 "\001", keypart_map=1,
    find_flag=HA_READ_KEY_EXACT) at /data/codebase/mysql-server-mysql-8.0.30/sql/handler.h:5289
#8  0x0000556713d4b10a in handler::ha_index_read_map (this=0x7ef6f40b3b90, buf=0x7ef6f409f330 "\001", key=0x7ef6f40a58d0 "\001",
    keypart_map=1, find_flag=HA_READ_KEY_EXACT) at /data/codebase/mysql-server-mysql-8.0.30/sql/handler.cc:3155
#9  0x0000556714142e8f in RefIterator<false>::Read (this=0x7ef6f40a5fe0)
    at /data/codebase/mysql-server-mysql-8.0.30/sql/iterators/ref_row_iterators.cc:384
#10 0x0000556713a8e6b3 in Query_expression::ExecuteIteratorQuery (this=0x7ef6f400a7a0, thd=0x7ef6f4001060)
    at /data/codebase/mysql-server-mysql-8.0.30/sql/sql_union.cc:1290
#11 0x0000556713a8ea3c in Query_expression::execute (this=0x7ef6f400a7a0, thd=0x7ef6f4001060)
    at /data/codebase/mysql-server-mysql-8.0.30/sql/sql_union.cc:1343
#12 0x00005567139d2eaa in Sql_cmd_dml::execute_inner (this=0x7ef6f401c020, thd=0x7ef6f4001060)
    at /data/codebase/mysql-server-mysql-8.0.30/sql/sql_select.cc:786
#13 0x00005567139d236e in Sql_cmd_dml::execute (this=0x7ef6f401c020, thd=0x7ef6f4001060)
    at /data/codebase/mysql-server-mysql-8.0.30/sql/sql_select.cc:586
#14 0x0000556713949287 in mysql_execute_command (thd=0x7ef6f4001060, first_level=true)
    at /data/codebase/mysql-server-mysql-8.0.30/sql/sql_parse.cc:4604
#15 0x000055671394b572 in dispatch_sql_command (thd=0x7ef6f4001060, parser_state=0x7efc000b2b90)
    at /data/codebase/mysql-server-mysql-8.0.30/sql/sql_parse.cc:5239
#16 0x0000556713940ff1 in dispatch_command (thd=0x7ef6f4001060, com_data=0x7efc000b34e0, command=COM_QUERY)
    at /data/codebase/mysql-server-mysql-8.0.30/sql/sql_parse.cc:1959
#17 0x000055671393f068 in do_command (thd=0x7ef6f4001060) at /data/codebase/mysql-server-mysql-8.0.30/sql/sql_parse.cc:1362
#18 0x0000556713b7b90f in handle_connection (arg=0x55671d310190)
    at /data/codebase/mysql-server-mysql-8.0.30/sql/conn_handler/connection_handler_per_thread.cc:302
#19 0x0000556715a9d66a in pfs_spawn_thread (arg=0x55671fabf620) at /data/codebase/mysql-server-mysql-8.0.30/storage/perfschema/pfs.cc:2942
#20 0x00007efc57ae0609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#21 0x00007efc569eb133 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

@lujiashun
Copy link
Author

REFERENCE: callstack of stonedb5.7(work well)

(gdb) bt
#0  TABLE::mark_column_used (this=0x7fadb800f200, thd=0x7fadb80a4270, field=0x7fadb8001d90, mark=32690)
    at /data/codebase/stonedb/sql/table.cc:6292
#1  0x000055d30d7d02f3 in find_field_in_table_ref (thd=0x7fadb8000e10, table_list=0x7fadb8006c50, name=0x7fadb80064f0 "PS_AVAILQTY",
    length=11, item_name=0x7fadb80064f0 "PS_AVAILQTY", db_name=0x0, table_name=0x0, ref=0x7fadb80066a8, want_privilege=1, allow_rowid=true,
    cached_field_index_ptr=0x7fadb8006bf8, register_tree_change=true, actual_table=0x7fb2ceabab60)
    at /data/codebase/stonedb/sql/sql_base.cc:7821
#2  0x000055d30d7d08cb in find_field_in_tables (thd=0x7fadb8000e10, item=0x7fadb8006b20, first_table=0x7fadb8006c50, last_table=0x0,
    ref=0x7fadb80066a8, report_error=IGNORE_EXCEPT_NON_UNIQUE, want_privilege=1, register_tree_change=true)
    at /data/codebase/stonedb/sql/sql_base.cc:7998
#3  0x000055d30d16ec49 in Item_field::fix_fields (this=0x7fadb8006b20, thd=0x7fadb8000e10, reference=0x7fadb80066a8)
    at /data/codebase/stonedb/sql/item.cc:5864
#4  0x000055d30d7d34ff in setup_fields (thd=0x7fadb8000e10, ref_pointer_array=..., fields=..., want_privilege=1,
    sum_func_list=0x7fadb8005d10, allow_sum_func=true, column_update=false) at /data/codebase/stonedb/sql/sql_base.cc:9138
#5  0x000055d30d89d23d in st_select_lex::prepare (this=0x7fadb8005bb0, thd=0x7fadb8000e10) at /data/codebase/stonedb/sql/sql_resolver.cc:197
#6  0x000055d30e1ba7ac in Tianmu::core::optimize_select (thd=0x7fadb8000e10, select_options=2147748608, result=0x7fadb8007560,
    select_lex=0x7fadb8005bb0, optimize_after_tianmu=@0x7fb2ceabb454: 0, free_join=@0x7fb2ceabb450: 1)
    at /data/codebase/stonedb/storage/tianmu/core/engine_execute.cpp:338
#7  0x000055d30e1ba0fa in Tianmu::core::Engine::HandleSelect (this=0x55d30fce9c20, thd=0x7fadb8000e10, lex=0x7fadb8003138,
    result=@0x7fb2ceabb458: 0x7fadb8007560, setup_tables_done_option=0, res=@0x7fb2ceabb44c: 32685, optimize_after_tianmu=@0x7fb2ceabb454: 0,
    tianmu_free_join=@0x7fb2ceabb450: 1, with_insert=0) at /data/codebase/stonedb/storage/tianmu/core/engine_execute.cpp:225
#8  0x000055d30e2b4720 in Tianmu::dbhandler::TIANMU_HandleSelect (thd=0x7fadb8000e10, lex=0x7fadb8003138,
    result=@0x7fb2ceabb458: 0x7fadb8007560, setup_tables_done_option=0, res=@0x7fb2ceabb44c: 32685, optimize_after_tianmu=@0x7fb2ceabb454: 0,
    tianmu_free_join=@0x7fb2ceabb450: 1, with_insert=0) at /data/codebase/stonedb/storage/tianmu/handler/ha_rcengine.cpp:81
#9  0x000055d30d859dc8 in execute_sqlcom_select (thd=0x7fadb8000e10, all_tables=0x7fadb8006c50)
    at /data/codebase/stonedb/sql/sql_parse.cc:5182
#10 0x000055d30d852e57 in mysql_execute_command (thd=0x7fadb8000e10, first_level=true) at /data/codebase/stonedb/sql/sql_parse.cc:2831
#11 0x000055d30d85ae56 in mysql_parse (thd=0x7fadb8000e10, parser_state=0x7fb2ceabc5f0) at /data/codebase/stonedb/sql/sql_parse.cc:5621
#12 0x000055d30d84fb13 in dispatch_command (thd=0x7fadb8000e10, com_data=0x7fb2ceabcea0, command=COM_QUERY)
    at /data/codebase/stonedb/sql/sql_parse.cc:1495
#13 0x000055d30d84e98a in do_command (thd=0x7fadb8000e10) at /data/codebase/stonedb/sql/sql_parse.cc:1034
#14 0x000055d30d997128 in handle_connection (arg=0x55d314951560)
    at /data/codebase/stonedb/sql/conn_handler/connection_handler_per_thread.cc:313
#15 0x000055d30e0e107d in pfs_spawn_thread (arg=0x55d3146bf590) at /data/codebase/stonedb/storage/perfschema/pfs.cc:2197
#16 0x00007fb2d568d609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#17 0x00007fb2d5461133 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
(gdb) c
Continuing.

Thread 120 "mysqld" hit Breakpoint 1, TABLE::mark_column_used (this=0x7fadb800f0d0, thd=0x7fadb80a4270, field=0x7fadb8001d90, mark=32690)
    at /data/codebase/stonedb/sql/table.cc:6292
6292    {
(gdb) bt
#0  TABLE::mark_column_used (this=0x7fadb800f0d0, thd=0x7fadb80a4270, field=0x7fadb8001d90, mark=32690)
    at /data/codebase/stonedb/sql/table.cc:6292
#1  0x000055d30d7d02f3 in find_field_in_table_ref (thd=0x7fadb8000e10, table_list=0x7fadb8006c50, name=0x7fadb80067a0 "ps_partkey",
    length=10, item_name=0x7fadb80067a0 "ps_partkey", db_name=0x0, table_name=0x0, ref=0x7fadb80073c0, want_privilege=1, allow_rowid=true,
    cached_field_index_ptr=0x7fadb80072d0, register_tree_change=true, actual_table=0x7fb2ceaba9f0)
    at /data/codebase/stonedb/sql/sql_base.cc:7821
#2  0x000055d30d7d08cb in find_field_in_tables (thd=0x7fadb8000e10, item=0x7fadb80071f8, first_table=0x7fadb8006c50, last_table=0x0,
    ref=0x7fadb80073c0, report_error=IGNORE_EXCEPT_NON_UNIQUE, want_privilege=1, register_tree_change=true)
    at /data/codebase/stonedb/sql/sql_base.cc:7998
#3  0x000055d30d16ec49 in Item_field::fix_fields (this=0x7fadb80071f8, thd=0x7fadb8000e10, reference=0x7fadb80073c0)
    at /data/codebase/stonedb/sql/item.cc:5864
#4  0x000055d30d1d9fee in Item_func::fix_func_arg (this=0x7fadb8007318, thd=0x7fadb8000e10, arg=0x7fadb80073c0)
    at /data/codebase/stonedb/sql/item_func.cc:263
#5  0x000055d30d1d9eee in Item_func::fix_fields (this=0x7fadb8007318, thd=0x7fadb8000e10, ref=0x7fadb8005c88)
    at /data/codebase/stonedb/sql/item_func.cc:249
#6  0x000055d30d89ffbd in st_select_lex::setup_conds (this=0x7fadb8005bb0, thd=0x7fadb8000e10)
    at /data/codebase/stonedb/sql/sql_resolver.cc:1191
#7  0x000055d30d89d319 in st_select_lex::prepare (this=0x7fadb8005bb0, thd=0x7fadb8000e10) at /data/codebase/stonedb/sql/sql_resolver.cc:212
#8  0x000055d30e1ba7ac in Tianmu::core::optimize_select (thd=0x7fadb8000e10, select_options=2147748608, result=0x7fadb8007560,
    select_lex=0x7fadb8005bb0, optimize_after_tianmu=@0x7fb2ceabb454: 0, free_join=@0x7fb2ceabb450: 1)
    at /data/codebase/stonedb/storage/tianmu/core/engine_execute.cpp:338
#9  0x000055d30e1ba0fa in Tianmu::core::Engine::HandleSelect (this=0x55d30fce9c20, thd=0x7fadb8000e10, lex=0x7fadb8003138,
    result=@0x7fb2ceabb458: 0x7fadb8007560, setup_tables_done_option=0, res=@0x7fb2ceabb44c: 32685, optimize_after_tianmu=@0x7fb2ceabb454: 0,
    tianmu_free_join=@0x7fb2ceabb450: 1, with_insert=0) at /data/codebase/stonedb/storage/tianmu/core/engine_execute.cpp:225
#10 0x000055d30e2b4720 in Tianmu::dbhandler::TIANMU_HandleSelect (thd=0x7fadb8000e10, lex=0x7fadb8003138,
    result=@0x7fb2ceabb458: 0x7fadb8007560, setup_tables_done_option=0, res=@0x7fb2ceabb44c: 32685, optimize_after_tianmu=@0x7fb2ceabb454: 0,
    tianmu_free_join=@0x7fb2ceabb450: 1, with_insert=0) at /data/codebase/stonedb/storage/tianmu/handler/ha_rcengine.cpp:81
#11 0x000055d30d859dc8 in execute_sqlcom_select (thd=0x7fadb8000e10, all_tables=0x7fadb8006c50)
    at /data/codebase/stonedb/sql/sql_parse.cc:5182
#12 0x000055d30d852e57 in mysql_execute_command (thd=0x7fadb8000e10, first_level=true) at /data/codebase/stonedb/sql/sql_parse.cc:2831
#13 0x000055d30d85ae56 in mysql_parse (thd=0x7fadb8000e10, parser_state=0x7fb2ceabc5f0) at /data/codebase/stonedb/sql/sql_parse.cc:5621
#14 0x000055d30d84fb13 in dispatch_command (thd=0x7fadb8000e10, com_data=0x7fb2ceabcea0, command=COM_QUERY)
    at /data/codebase/stonedb/sql/sql_parse.cc:1495
#15 0x000055d30d84e98a in do_command (thd=0x7fadb8000e10) at /data/codebase/stonedb/sql/sql_parse.cc:1034
#16 0x000055d30d997128 in handle_connection (arg=0x55d314951560)
    at /data/codebase/stonedb/sql/conn_handler/connection_handler_per_thread.cc:313
#17 0x000055d30e0e107d in pfs_spawn_thread (arg=0x55d3146bf590) at /data/codebase/stonedb/storage/perfschema/pfs.cc:2197
#18 0x00007fb2d568d609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#19 0x00007fb2d5461133 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

@lujiashun lujiashun assigned lujiashun and DandreChen and unassigned lujiashun Sep 22, 2022
DandreChen added a commit to DandreChen/stonedb that referenced this issue Sep 23, 2022
@DandreChen
Copy link
Collaborator

crash point is ASSERT_COLUMN_MARKED_FOR_READ , in below code:

longlong Field_long::val_int() const {
 ASSERT_COLUMN_MARKED_FOR_READ;
  int32 j;
  if (table->s->db_low_byte_first)
    j = sint4korr(ptr);
  else
    j = longget(ptr);
  return is_unsigned() ? (longlong)(uint32)j : (longlong)j;
}
#define ASSERT_COLUMN_MARKED_FOR_READ \
  assert(!table ||                    \
         (!table->read_set || bitmap_is_set(table->read_set, field_index())))

bitmap_is_set() return 0

static inline bool bitmap_is_set(const MY_BITMAP *map, uint bit) {
  assert(bit < map->n_bits);
  return ((uchar *)map->bitmap)[bit / 8] & (1 << (bit & 7));
}

@DandreChen
Copy link
Collaborator

BITMAP struct:

struct MY_BITMAP {
  my_bitmap_map *bitmap{nullptr};
  uint n_bits{0}; /* number of bits occupied by the above */
  my_bitmap_map last_word_mask{0};
  my_bitmap_map *last_word_ptr{nullptr};
};

@DandreChen
Copy link
Collaborator

DandreChen commented Sep 23, 2022

the 'bitmap' is marked for index field

Tianmu engine assign it not correct

@DandreChen
Copy link
Collaborator

appear this condition : union primary key

DandreChen added a commit to DandreChen/stonedb that referenced this issue Sep 23, 2022
…atom#534)

	details:
		if use the union primary query between two or more tables,
	the Tianmu engine may crash. because it do not init the bitmap of
	index field.
mergify bot pushed a commit that referenced this issue Sep 23, 2022
	details:
		if use the union primary query between two or more tables,
	the Tianmu engine may crash. because it do not init the bitmap of
	index field.
@RingsC RingsC changed the title bug: (stonedb8.0) TPCH Q20 crashed bug: (stonedb) TPCH Q20 crashed Sep 26, 2022
@DandreChen
Copy link
Collaborator

ACK

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-bug Something isn't working C-stonedb-8.0 associated with stonedb 8.0
Projects
Development

No branches or pull requests

3 participants