|
Ran into the same. Present in 11.0 only (not in 11.1). MTR Testcase:
--source include/have_innodb.inc
|
CREATE TABLE t1(c1 INT) ENGINE=InnoDB;
|
CREATE TABLE t2(c2 INT) ENGINE=InnoDB;
|
SELECT * FROM t1;
|
SET join_cache_level=3,use_stat_tables='never';
|
SELECT * FROM (SELECT * FROM t2 JOIN t1) AS ta NATURAL JOIN (SELECT * FROM t2 NATURAL JOIN t1) AS tb;
|
Leads to:
|
11.0.2 368dd22a816f3b437bccd0b9ff28b9de9b1abf0a (Debug)
|
mariadbd: /test/11.0_dbg/sql/sql_statistics.cc:4150: bool is_eits_usable(Field*): Assertion `field->orig_table->stats_is_read' failed.
|
|
11.0.2 368dd22a816f3b437bccd0b9ff28b9de9b1abf0a (Debug)
|
Core was generated by `/test/MD120523-mariadb-11.0.2-linux-x86_64-dbg/bin/mariadbd --no-defaults --cor'.
|
Program terminated with signal SIGABRT, Aborted.
|
#0 __pthread_kill_implementation (no_tid=0, signo=6, threadid=22856945555008)
|
at ./nptl/pthread_kill.c:44
|
[Current thread is 1 (Thread 0x14c9cc1ed640 (LWP 964941))]
|
(gdb) bt
|
#0 __pthread_kill_implementation (no_tid=0, signo=6, threadid=22856945555008) at ./nptl/pthread_kill.c:44
|
#1 __pthread_kill_internal (signo=6, threadid=22856945555008) at ./nptl/pthread_kill.c:78
|
#2 __GI___pthread_kill (threadid=22856945555008, signo=signo@entry=6) at ./nptl/pthread_kill.c:89
|
#3 0x000014c9f1842476 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
|
#4 0x000014c9f18287f3 in __GI_abort () at ./stdlib/abort.c:79
|
#5 0x000014c9f182871b in __assert_fail_base (fmt=0x14c9f19dd150 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x55e9417d7ee0 "field->orig_table->stats_is_read", file=0x55e9417d7c70 "/test/11.0_dbg/sql/sql_statistics.cc", line=4150, function=<optimized out>) at ./assert/assert.c:92
|
#6 0x000014c9f1839e96 in __GI___assert_fail (assertion=0x55e9417d7ee0 "field->orig_table->stats_is_read", file=0x55e9417d7c70 "/test/11.0_dbg/sql/sql_statistics.cc", line=4150, function=0x55e9417d7ba2 "bool is_eits_usable(Field*)") at ./assert/assert.c:101
|
#7 0x000055e940d60e7d in is_eits_usable (field=field@entry=0x14c9680769f8) at /test/11.0_dbg/sql/sql_statistics.cc:4150
|
#8 0x000055e940ceb8ff in hash_join_fanout (join=join@entry=0x14c96806fbc8, tab=tab@entry=0x14c9680800b8, remaining_tables=remaining_tables@entry=10, rnd_records=rnd_records@entry=1, hj_start_key=hj_start_key@entry=0x14c96807b338, stats_found=stats_found@entry=0x14c9cc1ea8f8) at /test/11.0_dbg/sql/sql_select.cc:8146
|
#9 0x000055e940cee8d4 in best_access_path (join=0x14c96806fbc8, s=s@entry=0x14c9680800b8, remaining_tables=remaining_tables@entry=10, join_positions=0x14c968080730, idx=idx@entry=2, disable_jbuf=disable_jbuf@entry=false, record_count=record_count@entry=1, pos=0x14c968082178, loose_scan_pos=0x14c9680822b8) at /test/11.0_dbg/sql/sql_select.cc:9093
|
#10 0x000055e940cf1951 in get_costs_for_tables (join=join@entry=0x14c96806fbc8, remaining_tables=remaining_tables@entry=10, idx=idx@entry=2, record_count=record_count@entry=1, trace_one_table=trace_one_table@entry=0x14c9cc1eac50, pos=0x14c9680806d0, pos@entry=0x14c9680806c8, store_position=store_position@entry=0x14c9cc1eac38, allowed_tables=<optimized out>, stop_on_eq_ref=<optimized out>) at /test/11.0_dbg/sql/sql_select.cc:11047
|
#11 0x000055e940cfa933 in best_extension_by_limited_search (join=join@entry=0x14c96806fbc8, remaining_tables=remaining_tables@entry=10, idx=idx@entry=2, record_count=record_count@entry=1, read_time=<optimized out>, search_depth=search_depth@entry=60, use_cond_selectivity=use_cond_selectivity@entry=4, processed_eq_ref_tables=processed_eq_ref_tables@entry=0x14c9cc1eadf0) at /test/11.0_dbg/sql/sql_select.cc:11304
|
#12 0x000055e940cfc194 in best_extension_by_limited_search (join=join@entry=0x14c96806fbc8, remaining_tables=remaining_tables@entry=14, idx=idx@entry=1, record_count=record_count@entry=1, read_time=<optimized out>, search_depth=search_depth@entry=61, use_cond_selectivity=use_cond_selectivity@entry=4, processed_eq_ref_tables=processed_eq_ref_tables@entry=0x14c9cc1eafc0) at /test/11.0_dbg/sql/sql_select.cc:11529
|
#13 0x000055e940cfc194 in best_extension_by_limited_search (join=join@entry=0x14c96806fbc8, remaining_tables=remaining_tables@entry=15, idx=idx@entry=0, record_count=record_count@entry=1, read_time=read_time@entry=0, search_depth=search_depth@entry=62, use_cond_selectivity=use_cond_selectivity@entry=4, processed_eq_ref_tables=processed_eq_ref_tables@entry=0x14c9cc1eb120) at /test/11.0_dbg/sql/sql_select.cc:11529
|
#14 0x000055e940cfdf54 in greedy_search (use_cond_selectivity=4, search_depth=62, remaining_tables=15, join=0x14c96806fbc8) at /test/11.0_dbg/sql/sql_select.cc:10275
|
#15 choose_plan (join=join@entry=0x14c96806fbc8, join_tables=<optimized out>, emb_sjm_nest=emb_sjm_nest@entry=0x0) at /test/11.0_dbg/sql/sql_select.cc:9796
|
#16 0x000055e940d24541 in make_join_statistics (join=join@entry=0x14c96806fbc8, tables_list=@0x14c9680134c0: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x14c9680795f8, last = 0x14c968078f90, elements = 4}, <No data fields>}, keyuse_array=keyuse_array@entry=0x14c96806ff30) at /test/11.0_dbg/sql/sql_select.cc:6085
|
#17 0x000055e940d2ba31 in JOIN::optimize_inner (this=this@entry=0x14c96806fbc8) at /test/11.0_dbg/sql/sql_select.cc:2577
|
#18 0x000055e940d2bf34 in JOIN::optimize (this=this@entry=0x14c96806fbc8) at /test/11.0_dbg/sql/sql_select.cc:1905
|
#19 0x000055e940d2c03d in mysql_select (thd=thd@entry=0x14c968000d58, tables=<optimized out>, fields=@0x14c968013560: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x14c968013880, last = 0x14c96807a5b8, elements = 2}, <No data fields>}, conds=0x0, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2164525824, result=0x14c968016cf8, unit=0x14c968004fa0, select_lex=0x14c9680132a8) at /test/11.0_dbg/sql/sql_select.cc:5144
|
#20 0x000055e940d2c822 in handle_select (thd=thd@entry=0x14c968000d58, lex=lex@entry=0x14c968004ec8, result=result@entry=0x14c968016cf8, setup_tables_done_option=setup_tables_done_option@entry=0) at /test/11.0_dbg/sql/sql_select.cc:616
|
#21 0x000055e940c8fc09 in execute_sqlcom_select (thd=thd@entry=0x14c968000d58, all_tables=0x14c968015d88) at /test/11.0_dbg/sql/sql_parse.cc:6279
|
#22 0x000055e940c9b23f in mysql_execute_command (thd=thd@entry=0x14c968000d58, is_called_from_prepared_stmt=is_called_from_prepared_stmt@entry=false) at /test/11.0_dbg/sql/sql_parse.cc:3949
|
#23 0x000055e940ca2599 in mysql_parse (thd=thd@entry=0x14c968000d58, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x14c9cc1ec240) at /test/11.0_dbg/sql/sql_parse.cc:8014
|
#24 0x000055e940ca472d in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x14c968000d58, packet=packet@entry=0x14c96800ae49 "SELECT * FROM (SELECT * FROM t2 JOIN t1) AS ta NATURAL JOIN (SELECT * FROM t2 NATURAL JOIN t1) AS tb", packet_length=packet_length@entry=100, blocking=blocking@entry=true) at /test/11.0_dbg/sql/sql_class.h:242
|
#25 0x000055e940ca658a in do_command (thd=0x14c968000d58, blocking=blocking@entry=true) at /test/11.0_dbg/sql/sql_parse.cc:1407
|
#26 0x000055e940dfb332 in do_handle_one_connection (connect=<optimized out>, connect@entry=0x55e94383b638, put_in_cache=put_in_cache@entry=true) at /test/11.0_dbg/sql/sql_connect.cc:1416
|
#27 0x000055e940dfb591 in handle_one_connection (arg=0x55e94383b638) at /test/11.0_dbg/sql/sql_connect.cc:1318
|
#28 0x000014c9f1894b43 in start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:442
|
#29 0x000014c9f1926a00 in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
|
Additionally, I noticed some some stack corruption when using MTR on a UB+ASAN debug build:
|
11.0.2 368dd22a816f3b437bccd0b9ff28b9de9b1abf0a (Debug, UBASAN)
|
Thread 13 (LWP 3101147):
|
#0 0x0000000000000000 in ?? ()
|
Backtrace stopped: Cannot access memory at address 0x0
|
|
|
The following slight testcase variation (hash_join_cardinality turned on):
--source include/have_innodb.inc
|
CREATE TABLE t1(c1 INT) ENGINE=InnoDB;
|
CREATE TABLE t2(c2 INT) ENGINE=InnoDB;
|
SELECT * FROM t1;
|
SET join_cache_level=3,use_stat_tables='never',optimizer_switch="hash_join_cardinality=on";
|
SELECT * FROM (SELECT * FROM t2 JOIN t1) AS ta NATURAL JOIN (SELECT * FROM t2 NATURAL JOIN t1) AS tb;
|
Produces a slightly different assert and affects more versions:
|
10.11.4 7c9f275ee4cd59212a85827626fbca2615d144d5 (Debug)
|
mariadbd: /test/10.11_dbg/sql/sql_statistics.cc:4111: bool is_eits_usable(Field*): Assertion `field->table->stats_is_read' failed.
|
|
10.11.4 7c9f275ee4cd59212a85827626fbca2615d144d5 (Debug)
|
Core was generated by `/test/MD120523-mariadb-10.11.4-linux-x86_64-dbg/bin/mariadbd --no-defaults --co'.
|
Program terminated with signal SIGABRT, Aborted.
|
#0 __pthread_kill_implementation (no_tid=0, signo=6, threadid=23433566979648)
|
at ./nptl/pthread_kill.c:44
|
[Current thread is 1 (Thread 0x15500d6f8640 (LWP 2588379))]
|
(gdb) bt
|
#0 __pthread_kill_implementation (no_tid=0, signo=6, threadid=23433566979648) at ./nptl/pthread_kill.c:44
|
#1 __pthread_kill_internal (signo=6, threadid=23433566979648) at ./nptl/pthread_kill.c:78
|
#2 __GI___pthread_kill (threadid=23433566979648, signo=signo@entry=6) at ./nptl/pthread_kill.c:89
|
#3 0x0000155032c42476 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
|
#4 0x0000155032c287f3 in __GI_abort () at ./stdlib/abort.c:79
|
#5 0x0000155032c2871b in __assert_fail_base (fmt=0x155032ddd150 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x559b1b5f897d "field->table->stats_is_read", file=0x559b1b5f8a68 "/test/10.11_dbg/sql/sql_statistics.cc", line=4111, function=<optimized out>) at ./assert/assert.c:92
|
#6 0x0000155032c39e96 in __GI___assert_fail (assertion=0x559b1b5f897d "field->table->stats_is_read", file=0x559b1b5f8a68 "/test/10.11_dbg/sql/sql_statistics.cc", line=4111, function=0x559b1b5f8999 "bool is_eits_usable(Field*)") at ./assert/assert.c:101
|
#7 0x0000559b1ab667b7 in is_eits_usable (field=field@entry=0x154fc80764a8) at /test/10.11_dbg/sql/sql_statistics.cc:4111
|
#8 0x0000559b1aaf6528 in hash_join_fanout (join=join@entry=0x154fc806f928, s=s@entry=0x154fc807f9e0, remaining_tables=remaining_tables@entry=10, rnd_records=rnd_records@entry=1, hj_start_key=hj_start_key@entry=0x154fc807ad30, stats_found=stats_found@entry=0x15500d6f5936) at /test/10.11_dbg/sql/sql_select.cc:7909
|
#9 0x0000559b1aafce4d in best_access_path (join=0x154fc806f928, s=s@entry=0x154fc807f9e0, remaining_tables=remaining_tables@entry=10, join_positions=0x154fc8080020, idx=idx@entry=2, disable_jbuf=disable_jbuf@entry=false, record_count=record_count@entry=1, pos=0x154fc8081678, loose_scan_pos=0x154fc8081788) at /test/10.11_dbg/sql/sql_select.cc:8646
|
#10 0x0000559b1aafee51 in get_costs_for_tables (join=join@entry=0x154fc806f928, remaining_tables=remaining_tables@entry=10, idx=idx@entry=2, record_count=record_count@entry=1, trace_one_table=trace_one_table@entry=0x15500d6f5c40, pos=0x154fc807ffc0, pos@entry=0x154fc807ffb8, store_position=store_position@entry=0x15500d6f5c28, allowed_tables=<optimized out>, stop_on_eq_ref=<optimized out>) at /test/10.11_dbg/sql/sql_select.cc:10345
|
#11 0x0000559b1ab038ed in best_extension_by_limited_search (join=join@entry=0x154fc806f928, remaining_tables=remaining_tables@entry=10, idx=idx@entry=2, record_count=record_count@entry=1, read_time=<optimized out>, search_depth=search_depth@entry=60, use_cond_selectivity=use_cond_selectivity@entry=4, processed_eq_ref_tables=processed_eq_ref_tables@entry=0x15500d6f5df0) at /test/10.11_dbg/sql/sql_select.cc:10604
|
#12 0x0000559b1ab0462a in best_extension_by_limited_search (join=join@entry=0x154fc806f928, remaining_tables=remaining_tables@entry=14, idx=idx@entry=1, record_count=record_count@entry=1, read_time=<optimized out>, search_depth=search_depth@entry=61, use_cond_selectivity=use_cond_selectivity@entry=4, processed_eq_ref_tables=processed_eq_ref_tables@entry=0x15500d6f5fd0) at /test/10.11_dbg/sql/sql_select.cc:10808
|
#13 0x0000559b1ab0462a in best_extension_by_limited_search (join=join@entry=0x154fc806f928, remaining_tables=remaining_tables@entry=15, idx=idx@entry=0, record_count=record_count@entry=1, read_time=read_time@entry=0, search_depth=search_depth@entry=62, use_cond_selectivity=use_cond_selectivity@entry=4, processed_eq_ref_tables=processed_eq_ref_tables@entry=0x15500d6f6120) at /test/10.11_dbg/sql/sql_select.cc:10808
|
#14 0x0000559b1ab059f8 in greedy_search (use_cond_selectivity=<optimized out>, search_depth=62, remaining_tables=15, join=0x154fc806f928) at /test/10.11_dbg/sql/sql_select.cc:9591
|
#15 choose_plan (join=join@entry=0x154fc806f928, join_tables=<optimized out>) at /test/10.11_dbg/sql/sql_select.cc:9157
|
#16 0x0000559b1ab2ae3e in make_join_statistics (join=join@entry=0x154fc806f928, tables_list=@0x154fc80134b0: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x154fc8079058, last = 0x154fc8070420, elements = 4}, <No data fields>}, keyuse_array=keyuse_array@entry=0x154fc806fc80) at /test/10.11_dbg/sql/sql_select.cc:6014
|
#17 0x0000559b1ab31eea in JOIN::optimize_inner (this=this@entry=0x154fc806f928) at /test/10.11_dbg/sql/sql_select.cc:2539
|
#18 0x0000559b1ab323de in JOIN::optimize (this=this@entry=0x154fc806f928) at /test/10.11_dbg/sql/sql_select.cc:1875
|
#19 0x0000559b1ab324ce in mysql_select (thd=thd@entry=0x154fc8000d58, tables=0x154fc8015d68, fields=@0x154fc8013550: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x154fc8013868, last = 0x154fc8079fd0, elements = 2}, <No data fields>}, conds=0x0, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2164525824, result=0x154fc8016cc8, unit=0x154fc8004f98, select_lex=0x154fc8013298) at /test/10.11_dbg/sql/sql_select.cc:5084
|
#20 0x0000559b1ab32c94 in handle_select (thd=thd@entry=0x154fc8000d58, lex=lex@entry=0x154fc8004ec0, result=result@entry=0x154fc8016cc8, setup_tables_done_option=setup_tables_done_option@entry=0) at /test/10.11_dbg/sql/sql_select.cc:586
|
#21 0x0000559b1aa9b6b1 in execute_sqlcom_select (thd=thd@entry=0x154fc8000d58, all_tables=0x154fc8015d68) at /test/10.11_dbg/sql/sql_parse.cc:6279
|
#22 0x0000559b1aaa6c51 in mysql_execute_command (thd=thd@entry=0x154fc8000d58, is_called_from_prepared_stmt=is_called_from_prepared_stmt@entry=false) at /test/10.11_dbg/sql/sql_parse.cc:3949
|
#23 0x0000559b1aaadfc0 in mysql_parse (thd=thd@entry=0x154fc8000d58, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x15500d6f7240) at /test/10.11_dbg/sql/sql_parse.cc:8017
|
#24 0x0000559b1aab0154 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x154fc8000d58, packet=packet@entry=0x154fc800ae39 "SELECT * FROM (SELECT * FROM t2 JOIN t1) AS ta NATURAL JOIN (SELECT * FROM t2 NATURAL JOIN t1) AS tb", packet_length=packet_length@entry=100, blocking=blocking@entry=true) at /test/10.11_dbg/sql/sql_class.h:243
|
#25 0x0000559b1aab2030 in do_command (thd=0x154fc8000d58, blocking=blocking@entry=true) at /test/10.11_dbg/sql/sql_parse.cc:1407
|
#26 0x0000559b1ac00248 in do_handle_one_connection (connect=<optimized out>, connect@entry=0x559b1eba55b8, put_in_cache=put_in_cache@entry=true) at /test/10.11_dbg/sql/sql_connect.cc:1416
|
#27 0x0000559b1ac004a7 in handle_one_connection (arg=0x559b1eba55b8) at /test/10.11_dbg/sql/sql_connect.cc:1318
|
#28 0x0000155032c94b43 in start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:442
|
#29 0x0000155032d26a00 in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
|
Bug confirmed present in:
MariaDB: 10.6.14 (dbg), 10.9.7 (dbg), 10.10.5 (dbg), 10.11.4 (dbg), 11.0.2 (dbg)
Across versions, two slightly different stacks are seen with the testcase:
field->table->stats_is_read|SIGABRT|is_eits_usable|hash_join_fanout|best_access_path|best_extension_by_limited_search
|
field->table->stats_is_read|SIGABRT|is_eits_usable|hash_join_fanout|best_access_path|get_costs_for_tables
|
This can be compared with the original 11.0-only issue which produced:
field->orig_table->stats_is_read|SIGABRT|is_eits_usable|hash_join_fanout|best_access_path|get_costs_for_tables
|
|