[MDEV-13107] Database service (MySQL) stops after show table status command Created: 2017-06-16  Updated: 2018-08-31  Resolved: 2017-06-29

Status: Closed
Project: MariaDB Server
Component/s: Optimizer - CTE, Views
Affects Version/s: 10.2.6
Fix Version/s: 10.2.7

Type: Bug Priority: Major
Reporter: Tadas Balaišis Assignee: Igor Babaev
Resolution: Fixed Votes: 0
Labels: None

Attachments: Zip Archive eksp full database export_20170616.zip     File eksp ta_triggers0 bad 20170616.sql     File eksp ta_triggers0 good 20170616.sql     Zip Archive error.zip    
Issue Links:
Relates
relates to MDEV-17107 Assertion `table_list->table' failed ... Closed

 Description   

Database service (MySQL) stops after "show table status" command issued after specific view was created in user database. When service restored, new session reproduces the crash: "show table status" ends with:

show table status;
/* SQL Error (2013): Lost connection to MySQL server during query */

If I remove the view, everything is fine again, no crash. When I recreate the view (without any error), crash also returns.
I tried to simplify the query of problematic view. Here are two versions attached: "good" - simplified enough to give no crash, "bad" - giving the crash.
The difference is that in "bad" query there are two inline views in WITH construction; in "good" query there is only one.



 Comments   
Comment by Elena Stepanova [ 2017-06-16 ]

The view uses many tables, I can't re-create it locally without those tables being present. Could you please provide the dump of the schema (only structures, without the data)?
Please also paste the crash report from the error log.
Thanks.

Comment by Tadas Balaišis [ 2017-06-16 ]

Check new attachments.

Comment by Alice Sherepa [ 2017-06-19 ]

reproducible on 10.2.6, 10.2.5 ( Ubuntu 16.04 )

CREATE TABLE `t1` (`i1` int  NOT NULL, primary key (i1));
 
CREATE TABLE  `t2` (`i1` int  NOT NULL ,
  	CONSTRAINT `t2_tab_fk` FOREIGN KEY (`i1`) REFERENCES `t1` (`i1`) ON DELETE CASCADE);
 
create or replace view v1 as
with 
	e as(select t1.i1,s.a from t1  join (select 1 a) s),
	k as(select 1 from t2  join e using (i1))
SELECT 1;
 
show table status;

stack trace in commit 0992be927e1c686c39c39fe53fc2a7869d55143d

Version: '10.2.7-MariaDB-debug'  socket: '/tmp/mysql.sock'  port: 3306  Source distribution
mysqld: /home/alice/git/10.2/sql/sql_base.cc:5573: Field* find_field_in_table_ref(THD*, TABLE_LIST*, const char*, uint, const char*, const char*, const char*, Item**, bool, bool, uint*, bool, TABLE_LIST**): Assertion `table_list->table' failed.
170621 15:02:59 [ERROR] mysqld got signal 6 ;
This could be because you hit a bug. It is also possible that this binary
or one of the libraries it was linked against is corrupt, improperly built,
or misconfigured. This error can also be caused by malfunctioning hardware.
 
To report this bug, see https://mariadb.com/kb/en/reporting-bugs
 
We will try our best to scrape up some info that will hopefully help
diagnose the problem, but since we have already crashed, 
something is definitely wrong and this may fail.
 
Server version: 10.2.7-MariaDB-debug
key_buffer_size=134217728
read_buffer_size=131072
max_used_connections=1
max_threads=153
thread_count=7
It is possible that mysqld could use up to 
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 467291 K  bytes of memory
Hope that's ok; if not, decrease some variables in the equation.
 
Thread pointer: 0x7fede0000b00
Attempting backtrace. You can use the following information to find out
where mysqld died. If you see no messages after this, something went
terribly wrong...
stack_bottom = 0x7fee3c333ec0 thread_stack 0x49000
/data/bld/10.2/bin/mysqld(my_print_stacktrace+0x38)[0x562832f0287e]
/data/bld/10.2/bin/mysqld(handle_fatal_signal+0x3a3)[0x56283279392c]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x11390)[0x7fee52a81390]
/lib/x86_64-linux-gnu/libc.so.6(gsignal+0x38)[0x7fee51e3a428]
/lib/x86_64-linux-gnu/libc.so.6(abort+0x16a)[0x7fee51e3c02a]
/lib/x86_64-linux-gnu/libc.so.6(+0x2dbd7)[0x7fee51e32bd7]
/lib/x86_64-linux-gnu/libc.so.6(+0x2dc82)[0x7fee51e32c82]
/data/bld/10.2/bin/mysqld(_Z23find_field_in_table_refP3THDP10TABLE_LISTPKcjS4_S4_S4_PP4ItembbPjbPS2_+0x3b0)[0x5628324be673]
/data/bld/10.2/bin/mysqld(_Z20find_field_in_tablesP3THDP10Item_identP10TABLE_LISTS4_PP4Item27find_item_error_report_typebb+0x639)[0x5628324bf1d1]
/data/bld/10.2/bin/mysqld(_ZN10Item_field10fix_fieldsEP3THDPP4Item+0xf9)[0x5628327b6cc5]
/data/bld/10.2/bin/mysqld(_Z12setup_fieldsP3THD20Bounds_checked_arrayIP4ItemER4ListIS2_E17enum_mark_columnsPS6_b+0x34c)[0x5628324c1ea4]
/data/bld/10.2/bin/mysqld(_ZN4JOIN7prepareEP10TABLE_LISTjP4ItemjP8st_orderbS5_S3_S5_P13st_select_lexP18st_select_lex_unit+0x6a7)[0x562832567a1f]
/data/bld/10.2/bin/mysqld(_ZN18st_select_lex_unit7prepareEP3THDP13select_resultm+0x82f)[0x56283260ba73]
/data/bld/10.2/bin/mysqld(_Z21mysql_derived_prepareP3THDP3LEXP10TABLE_LIST+0x5c2)[0x5628324f9677]
/data/bld/10.2/bin/mysqld(_Z20mysql_handle_derivedP3LEXj+0x24c)[0x5628324f8383]
/data/bld/10.2/bin/mysqld(_Z30open_normal_and_derived_tablesP3THDP10TABLE_LISTjj+0xc2)[0x5628324bc604]
/data/bld/10.2/bin/mysqld(+0x6424c6)[0x5628325c14c6]
/data/bld/10.2/bin/mysqld(_Z14get_all_tablesP3THDP10TABLE_LISTP4Item+0x95b)[0x5628325c2cd7]
/data/bld/10.2/bin/mysqld(_Z24get_schema_tables_resultP4JOIN23enum_schema_table_state+0x3c7)[0x5628325d2d5c]
/data/bld/10.2/bin/mysqld(_ZN4JOIN10exec_innerEv+0x887)[0x5628325714b1]
/data/bld/10.2/bin/mysqld(_ZN4JOIN4execEv+0xc8)[0x562832570b8e]
/data/bld/10.2/bin/mysqld(_Z12mysql_selectP3THDP10TABLE_LISTjR4ListI4ItemEPS4_jP8st_orderS9_S7_S9_yP13select_resultP18st_select_lex_unitP13st_select_lex+0x2f3)[0x562832571d2e]
/data/bld/10.2/bin/mysqld(_Z13handle_selectP3THDP3LEXP13select_resultm+0x15f)[0x562832566725]
/data/bld/10.2/bin/mysqld(+0x5b3640)[0x562832532640]
/data/bld/10.2/bin/mysqld(_Z21mysql_execute_commandP3THD+0x1849)[0x562832528390]
/data/bld/10.2/bin/mysqld(_Z11mysql_parseP3THDPcjP12Parser_statebb+0x29d)[0x562832535fc9]
/data/bld/10.2/bin/mysqld(_Z16dispatch_command19enum_server_commandP3THDPcjbb+0xfe6)[0x562832523dc9]
/data/bld/10.2/bin/mysqld(_Z10do_commandP3THD+0x712)[0x562832522703]
/data/bld/10.2/bin/mysqld(_Z24do_handle_one_connectionP7CONNECT+0x1ca)[0x56283266d9ba]
/data/bld/10.2/bin/mysqld(handle_one_connection+0x30)[0x56283266d73a]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x76ba)[0x7fee52a776ba]
/lib/x86_64-linux-gnu/libc.so.6(clone+0x6d)[0x7fee51f0c3dd]
 
Trying to get some variables.
Some pointers may be invalid and cause the dump to abort.
Query (0x7fede0010e98): show table status
Connection ID (thread ID): 8
Status: NOT_KILLED
 
Optimizer switch: index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on

coredump

Thread 1 (Thread 0x7fee3c334700 (LWP 14639)):
#0  0x00007fee51e3a428 in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:54
#1  0x00007fee51e3c02a in __GI_abort () at abort.c:89
#2  0x00007fee51e32bd7 in __assert_fail_base (fmt=<optimized out>, assertion=assertion@entry=0x562832f85e85 "table_list->table", file=file@entry=0x562832f85230 "/home/alice/git/10.2/sql/sql_base.cc", line=line@entry=5573, function=function@entry=0x562832f879e0 <find_field_in_table_ref(THD*, TABLE_LIST*, char const*, unsigned int, char const*, char const*, char const*, Item**, bool, bool, unsigned int*, bool, TABLE_LIST**)::__PRETTY_FUNCTION__> "Field* find_field_in_table_ref(THD*, TABLE_LIST*, const char*, uint, const char*, const char*, const char*, Item**, bool, bool, uint*, bool, TABLE_LIST**)") at assert.c:92
#3  0x00007fee51e32c82 in __GI___assert_fail (assertion=0x562832f85e85 "table_list->table", file=0x562832f85230 "/home/alice/git/10.2/sql/sql_base.cc", line=5573, function=0x562832f879e0 <find_field_in_table_ref(THD*, TABLE_LIST*, char const*, unsigned int, char const*, char const*, char const*, Item**, bool, bool, unsigned int*, bool, TABLE_LIST**)::__PRETTY_FUNCTION__> "Field* find_field_in_table_ref(THD*, TABLE_LIST*, const char*, uint, const char*, const char*, const char*, Item**, bool, bool, uint*, bool, TABLE_LIST**)") at assert.c:101
#4  0x00005628324be673 in find_field_in_table_ref (thd=0x7fede0000b00, table_list=0x7fede008f960, name=0x7fede006aca0 "a", length=1, item_name=0x7fede006adb8 "a", db_name=0x0, table_name=0x7fede006ac98 "s", ref=0x7fede006adb0, check_privileges=false, allow_rowid=true, cached_field_index_ptr=0x7fede006ad6c, register_tree_change=true, actual_table=0x7fee3c32f708) at /home/alice/git/10.2/sql/sql_base.cc:5573
#5  0x00005628324bf1d1 in find_field_in_tables (thd=0x7fede0000b00, item=0x7fede006aca8, first_table=0x7fede008e850, last_table=0x0, ref=0x7fede006adb0, report_error=IGNORE_EXCEPT_NON_UNIQUE, check_privileges=true, register_tree_change=true) at /home/alice/git/10.2/sql/sql_base.cc:5873
#6  0x00005628327b6cc5 in Item_field::fix_fields (this=0x7fede006aca8, thd=0x7fede0000b00, reference=0x7fede006adb0) at /home/alice/git/10.2/sql/item.cc:5443
#7  0x00005628324c1ea4 in setup_fields (thd=0x7fede0000b00, ref_pointer_array=..., fields=..., mark_used_columns=MARK_COLUMNS_READ, sum_func_list=0x7fede0093d50, allow_sum_func=true) at /home/alice/git/10.2/sql/sql_base.cc:7053
#8  0x0000562832567a1f in JOIN::prepare (this=0x7fede0093a38, tables_init=0x7fede008e850, wild_num=0, conds_init=0x0, og_num=0, order_init=0x0, skip_order_by=false, group_init=0x0, having_init=0x0, proc_param_init=0x0, select_lex_arg=0x7fede006a058, unit_arg=0x7fede006a430) at /home/alice/git/10.2/sql/sql_select.cc:806
#9  0x000056283260ba73 in st_select_lex_unit::prepare (this=0x7fede006a430, thd_arg=0x7fede0000b00, sel_result=0x7fede0093968, additional_options=0) at /home/alice/git/10.2/sql/sql_union.cc:560
#10 0x00005628324f9677 in mysql_derived_prepare (thd=0x7fede0000b00, lex=0x7fee3c330160, derived=0x7fede0092238) at /home/alice/git/10.2/sql/sql_derived.cc:743
#11 0x00005628324f8383 in mysql_handle_derived (lex=0x7fee3c330160, phases=34) at /home/alice/git/10.2/sql/sql_derived.cc:121
#12 0x00005628324bc604 in open_normal_and_derived_tables (thd=0x7fede0000b00, tables=0x7fede0068090, flags=1026, dt_phases=34) at /home/alice/git/10.2/sql/sql_base.cc:4746
#13 0x00005628325c14c6 in fill_schema_table_by_open (thd=0x7fede0000b00, is_show_fields_or_keys=false, table=0x7fede0057dc8, schema_table=0x562833867040 <schema_tables+1920>, orig_db_name=0x7fede0016a78, orig_table_name=0x7fede0016da0, open_tables_state_backup=0x7fee3c331860, can_deadlock=false) at /home/alice/git/10.2/sql/sql_show.cc:4272
#14 0x00005628325c2cd7 in get_all_tables (thd=0x7fede0000b00, tables=0x7fede00126d8, cond=0x0) at /home/alice/git/10.2/sql/sql_show.cc:4916
#15 0x00005628325d2d5c in get_schema_tables_result (join=0x7fede0014768, executed_place=PROCESSED_BY_JOIN_EXEC) at /home/alice/git/10.2/sql/sql_show.cc:8263
#16 0x00005628325714b1 in JOIN::exec_inner (this=0x7fede0014768) at /home/alice/git/10.2/sql/sql_select.cc:3437
#17 0x0000562832570b8e in JOIN::exec (this=0x7fede0014768) at /home/alice/git/10.2/sql/sql_select.cc:3274
#18 0x0000562832571d2e in mysql_select (thd=0x7fede0000b00, tables=0x7fede00126d8, wild_num=0, fields=..., conds=0x0, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2684619520, result=0x7fede0014748, unit=0x7fede00045e0, select_lex=0x7fede0004d18) at /home/alice/git/10.2/sql/sql_select.cc:3668
#19 0x0000562832566725 in handle_select (thd=0x7fede0000b00, lex=0x7fede0004518, result=0x7fede0014748, setup_tables_done_option=0) at /home/alice/git/10.2/sql/sql_select.cc:373
#20 0x0000562832532640 in execute_sqlcom_select (thd=0x7fede0000b00, all_tables=0x7fede00126d8) at /home/alice/git/10.2/sql/sql_parse.cc:6438
#21 0x0000562832528390 in mysql_execute_command (thd=0x7fede0000b00) at /home/alice/git/10.2/sql/sql_parse.cc:3453
#22 0x0000562832535fc9 in mysql_parse (thd=0x7fede0000b00, rawbuf=0x7fede0010e98 "show table status", length=17, parser_state=0x7fee3c333250, is_com_multi=false, is_next_command=false) at /home/alice/git/10.2/sql/sql_parse.cc:7875
#23 0x0000562832523dc9 in dispatch_command (command=COM_QUERY, thd=0x7fede0000b00, packet=0x7fede00086c1 "show table status", packet_length=17, is_com_multi=false, is_next_command=false) at /home/alice/git/10.2/sql/sql_parse.cc:1817
#24 0x0000562832522703 in do_command (thd=0x7fede0000b00) at /home/alice/git/10.2/sql/sql_parse.cc:1362
#25 0x000056283266d9ba in do_handle_one_connection (connect=0x562835a88f70) at /home/alice/git/10.2/sql/sql_connect.cc:1354
#26 0x000056283266d73a in handle_one_connection (arg=0x562835a88f70) at /home/alice/git/10.2/sql/sql_connect.cc:1260
#27 0x00007fee52a776ba in start_thread (arg=0x7fee3c334700) at pthread_create.c:333
#28 0x00007fee51f0c3dd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109

Comment by Igor Babaev [ 2017-06-27 ]

This bug can be reproduced with the following test case:

create table t1(a int) engine=myisam;
insert into t1 values (3), (1), (2);
create table t2 (b int) engine=myisam;
insert into t2 values (2), (10);
 
create view v1 as
with t as (select s.a from (select t1.a from t1) s),
     r as(select t.a from t2, t where t2.b=t.a)
 select a from r;
 
show table status;

Comment by Igor Babaev [ 2017-06-27 ]

After having fixed the above problem I still have an assertion abort for the command:

show create view v1;
mysqld: /home/igor/maria-git/10.2/sql/sql_base.cc:5573: Field* find_field_in_table_ref(THD*, TABLE_LIST*, const char*, uint, const char*, const char*, const char*, Item**, bool, bool, uint*, bool, TABLE_LIST**): Assertion `table_list->table' failed.

Comment by Igor Babaev [ 2017-06-27 ]

However after my additional fix for SHOW CREATE VIEW any attempt to connect to the server by another client caused the same assertion abort though with a different stack.

Comment by Igor Babaev [ 2017-06-29 ]

The fix for this bug was pushed into the 10.2 tree.

Generated at Thu Feb 08 08:02:57 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.