assertion in ha_maria::enable_indexes with derived_with_keys=on

Bug #879939 reported by Philip Stoev
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
MariaDB
Fix Released
High
Michael Widenius

Bug Description

Assertion:

mysqld: ha_maria.cc:1952: virtual int ha_maria::enable_indexes(uint): Assertion `thd->killed != 0' failed.

#8 0x00399d98 in __assert_fail () from /lib/libc.so.6
#9 0x08554be8 in ha_maria::enable_indexes (this=0xae6f4798, mode=2) at ha_maria.cc:1952
#10 0x0855535c in ha_maria::end_bulk_insert (this=0xae6f4798) at ha_maria.cc:2135
#11 0x0834e7ed in handler::ha_end_bulk_insert (this=0xae6f4798) at handler.h:1778
#12 0x0833caac in create_internal_tmp_table_from_heap2 (thd=0x9f1b6e0, table=0xae6218a8, start_recinfo=0xae6222d8, recinfo=0xae614acc, error=135,
    ignore_last_dupp_key_error=true, hton=0x9eb7648, proc_info=0x88f0793 "converting HEAP to Aria") at sql_select.cc:14540
#13 0x0833c668 in create_internal_tmp_table_from_heap (thd=0x9f1b6e0, table=0xae6218a8, start_recinfo=0xae6222d8, recinfo=0xae614acc, error=135,
    ignore_last_dupp_key_error=true) at sql_select.cc:14287
#14 0x0846d899 in select_union::send_data (this=0xae614a88, values=...) at sql_union.cc:74
#15 0x08340223 in end_send (join=0xae635f70, join_tab=0xae62ee50, end_of_records=false) at sql_select.cc:16142
#16 0x082f38db in JOIN_CACHE::generate_full_extensions (this=0xae62f1d8,
    rec_ptr=0xae63b9f9 "\374\003USA\rWichita Falls\374\003USA\rWinston-Salem\374\003USA\tWorcester\374\003USA\aYonkers") at sql_join_cache.cc:2356
#17 0x082f3633 in JOIN_CACHE::join_matching_records (this=0xae62f1d8, skip_last=false) at sql_join_cache.cc:2248
#18 0x082f30f3 in JOIN_CACHE::join_records (this=0xae62f1d8, skip_last=false) at sql_join_cache.cc:2045
#19 0x0833d9ea in sub_select_cache (join=0xae635f70, join_tab=0xae62ec4c, end_of_records=true) at sql_select.cc:14901
#20 0x0833dc02 in sub_select (join=0xae635f70, join_tab=0xae62ea48, end_of_records=true) at sql_select.cc:15063
#21 0x0833d6f1 in do_select (join=0xae635f70, fields=0xae613384, table=0x0, procedure=0x0) at sql_select.cc:14785
#22 0x08321f51 in JOIN::exec (this=0xae635f70) at sql_select.cc:2679
#23 0x0832277e in mysql_select (thd=0x9f1b6e0, rref_pointer_array=0xae61342c, tables=0xae613880, wild_num=0, fields=..., conds=0x0, og_num=0, order=0x0,
    group=0x0, having=0x0, proc_param=0x0, select_options=2416200192, result=0xae614a88, unit=0xae6134c8, select_lex=0xae6132f0) at sql_select.cc:2900
#24 0x0847199f in mysql_derived_fill (thd=0x9f1b6e0, lex=0x9f1cde4, derived=0xae614008) at sql_derived.cc:885
#25 0x0847081f in mysql_handle_single_derived (lex=0x9f1cde4, derived=0xae614008, phases=96) at sql_derived.cc:174
#26 0x083326f7 in st_join_table::preread_init (this=0xae62fbec) at sql_select.cc:9697
#27 0x0833dc75 in sub_select (join=0xae6290c0, join_tab=0xae62fbec, end_of_records=false) at sql_select.cc:15075
#28 0x0833d6c5 in do_select (join=0xae6290c0, fields=0x9f1d1b4, table=0x0, procedure=0x0) at sql_select.cc:14783
#29 0x08321f51 in JOIN::exec (this=0xae6290c0) at sql_select.cc:2679
#30 0x0832277e in mysql_select (thd=0x9f1b6e0, rref_pointer_array=0x9f1d25c, tables=0xae614008, wild_num=1, fields=..., conds=0x0, og_num=0, order=0x0,
    group=0x0, having=0x0, proc_param=0x0, select_options=2147764736, result=0xae614a70, unit=0x9f1ce40, select_lex=0x9f1d120) at sql_select.cc:2900
#31 0x0831a54f in handle_select (thd=0x9f1b6e0, lex=0x9f1cde4, result=0xae614a70, setup_tables_done_option=0) at sql_select.cc:283
#32 0x082b4d08 in execute_sqlcom_select (thd=0x9f1b6e0, all_tables=0xae614008) at sql_parse.cc:5112
#33 0x082abac5 in mysql_execute_command (thd=0x9f1b6e0) at sql_parse.cc:2250
#34 0x082b7337 in mysql_parse (thd=0x9f1b6e0, rawbuf=0xae612ec0 "SELECT * \nFROM (\nSELECT t1.*\nFROM t1, t2\n) AS alias1\nJOIN t3 ON ( t3.a = alias1.b )",
    length=83, found_semicolon=0xae983228) at sql_parse.cc:6112
#35 0x082a9714 in dispatch_command (command=COM_QUERY, thd=0x9f1b6e0, packet=0x9f74321 "", packet_length=83) at sql_parse.cc:1221
#36 0x082a8b6f in do_command (thd=0x9f1b6e0) at sql_parse.cc:916
#37 0x082a5b53 in handle_one_connection (arg=0x9f1b6e0) at sql_connect.cc:1191
#38 0x00821919 in start_thread () from /lib/libpthread.so.0
#39 0x00453cce in clone () from /lib/libc.so.6

explain:

id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t3 system NULL NULL NULL NULL 1
1 PRIMARY <derived2> ref key0 key0 39 const 10 Using where
2 DERIVED t1 ALL NULL NULL NULL NULL 142
2 DERIVED t2 ALL NULL NULL NULL NULL 142 Using join buffer (flat, BNL join)

bzr version-info
revision-id: <email address hidden>
date: 2011-10-22 07:19:43 -0700
build-date: 2011-10-22 17:50:21 +0300
revno: 3247
branch-nick: maria-5.3

minimal switch: derived_with_keys=ON
full switch: index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=on,firstmatch=off,loosescan=off,materialization=off,in_to_exists=on,semijoin=off,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=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on

bzr version-info
revision-id: <email address hidden>
date: 2011-10-22 07:19:43 -0700
build-date: 2011-10-22 17:51:21 +0300
revno: 3247
branch-nick: maria-5.3

test case. Seems that longer tables are required for this bug to show up:

CREATE TABLE t2 ( a varchar(3)) ;
INSERT INTO t2 VALUES ('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA'),('USA');

CREATE TABLE t1 ( a varchar(3), b varchar(35)) ENGINE=MyISAM;
INSERT INTO t1 VALUES ('USA','Lansing'),('USA','Laredo'),('USA','Las Vegas'),('USA','Lexington-Fayett'),('USA','Lincoln'),('USA','Little Rock'),('USA','Livonia'),('USA','Long Beach'),('USA','Los Angeles'),('USA','Louisville'),('USA','Lowell'),('USA','Lubbock'),('USA','Macon'),('USA','Madison'),('USA','Manchester'),('USA','McAllen'),('USA','Memphis'),('USA','Mesa'),('USA','Mesquite'),('USA','Metairie'),('USA','Miami'),('USA','Miami Beach'),('USA','Midland'),('USA','Milwaukee'),('USA','Minneapolis'),('USA','Mission Viejo'),('USA','Mobile'),('USA','Modesto'),('USA','Montgomery'),('USA','Moreno Valley'),('USA','Naperville'),('USA','Nashville-Davids'),('USA','New Bedford'),('USA','New Haven'),('USA','New Orleans'),('USA','New York'),('USA','Newark'),('USA','Newport News'),('USA','Norfolk'),('USA','Norman'),('USA','North Las Vegas'),('USA','Norwalk'),('USA','Oakland'),('USA','Oceanside'),('USA','Odessa'),('USA','Oklahoma City'),('USA','Omaha'),('USA','Ontario'),('USA','Orange'),('USA','Orlando'),('USA','Overland Park'),('USA','Oxnard'),('USA','Palmdale'),('USA','Paradise'),('USA','Pasadena'),('USA','Pasadena'),('USA','Paterson'),('USA','Pembroke Pines'),('USA','Peoria'),('USA','Peoria'),('USA','Philadelphia'),('USA','Phoenix'),('USA','Pittsburgh'),('USA','Plano'),('USA','Pomona'),('USA','Portland'),('USA','Portsmouth'),('USA','Providence'),('USA','Provo'),('USA','Pueblo'),('USA','Raleigh'),('USA','Rancho Cucamonga'),('USA','Reno'),('USA','Richmond'),('USA','Richmond'),('USA','Riverside'),('USA','Roanoke'),('USA','Rochester'),('USA','Rockford'),('USA','Sacramento'),('USA','Saint Louis'),('USA','Saint Paul'),('USA','Saint Petersburg'),('USA','Salem'),('USA','Salinas'),('USA','Salt Lake City'),('USA','San Antonio'),('USA','San Bernardino'),('USA','San Buenaventura'),('USA','San Diego'),('USA','San Francisco'),('USA','San Jose'),('USA','San Mateo'),('USA','Sandy'),('USA','Santa Ana'),('USA','Santa Clara'),('USA','Santa Clarita'),('USA','Santa Monica'),('USA','Santa Rosa'),('USA','Savannah'),('USA','Scottsdale'),('USA','Seattle'),('USA','Shreveport'),('USA','Simi Valley'),('USA','Sioux Falls'),('USA','South Bend'),('USA','Spokane'),('USA','Springfield'),('USA','Springfield'),('USA','Springfield'),('USA','Stamford'),('USA','Sterling Heights'),('USA','Stockton'),('USA','Sunnyvale'),('USA','Sunrise Manor'),('USA','Syracuse'),('USA','Tacoma'),('USA','Tallahassee'),('USA','Tampa'),('USA','Tempe'),('USA','Thousand Oaks'),('USA','Toledo'),('USA','Topeka'),('USA','Torrance'),('USA','Tucson'),('USA','Tulsa'),('USA','Vallejo'),('USA','Vancouver'),('USA','Virginia Beach'),('USA','Visalia'),('USA','Waco'),('USA','Warren'),('USA','Washington'),('USA','Waterbury'),('USA','West Covina'),('USA','West Valley City'),('USA','Westminster'),('USA','Wichita'),('USA','Wichita Falls'),('USA','Winston-Salem'),('USA','Worcester'),('USA','Yonkers');

CREATE TABLE t3 ( a varchar(3)) ENGINE=MyISAM;
INSERT INTO t3 VALUES ('USA');

SET SESSION optimizer_switch = 'derived_with_keys=on';

SELECT *
FROM (
        SELECT t1.*
        FROM t1, t2
) AS alias1
JOIN t3 ON ( t3.a = alias1.b );

Related branches

Changed in maria:
assignee: nobody → Igor Babaev (igorb-seattle)
milestone: none → 5.3
Revision history for this message
Philip Stoev (pstoev-askmonty) wrote :
Download full text (6.1 KiB)

 Valgrind warnings:

==2976== Thread 4:
==2976== Conditional jump or move depends on uninitialised value(s)
==2976== at 0x87BABDF: longlong10_to_str (in /home/philips/bzr/maria-5.3/sql/mysqld)
==2976==
==2976== Conditional jump or move depends on uninitialised value(s)
==2976== at 0x87BABF2: longlong10_to_str (in /home/philips/bzr/maria-5.3/sql/mysqld)
==2976==
==2976== Conditional jump or move depends on uninitialised value(s)
==2976== at 0x87BABF9: longlong10_to_str (in /home/philips/bzr/maria-5.3/sql/mysqld)
==2976==
==2976== Conditional jump or move depends on uninitialised value(s)
==2976== at 0x4006FD0: strnlen (mc_replace_strmem.c:263)
==2976== by 0x87D27A6: process_str_arg (my_vsnprintf.c:195)
==2976== by 0x87D3AE7: my_vsnprintf_ex (my_vsnprintf.c:567)
==2976== by 0x87D3CE7: my_vsnprintf (my_vsnprintf.c:624)
==2976== by 0x854F7CD: _ma_check_print_msg(st_handler_check_param*, char const*, char const*, char*) (ha_maria.cc:306)
==2976== by 0x85511FA: _ma_check_print_warning (ha_maria.cc:784)
==2976== by 0x85C985E: sort_key_write (ma_check.c:5503)
==2976== by 0x860BD14: write_index (ma_sort.c:772)
==2976== by 0x8609DB6: _ma_create_index_by_sort (ma_sort.c:201)
==2976== by 0x85C433F: maria_repair_by_sort (ma_check.c:3877)
==2976== by 0x8553E30: ha_maria::repair(THD*, st_handler_check_param*, bool) (ha_maria.cc:1620)
==2976== by 0x8554B5B: ha_maria::enable_indexes(unsigned int) (ha_maria.cc:1946)
==2976== by 0x855536B: ha_maria::end_bulk_insert() (ha_maria.cc:2135)
==2976== by 0x834E7FC: handler::ha_end_bulk_insert() (handler.h:1778)
==2976== by 0x833CABB: create_internal_tmp_table_from_heap2(THD*, st_table*, st_maria_columndef*, st_maria_columndef**, int, bool, handlerton*, char const*
) (sql_select.cc:14540)
==2976== by 0x833C677: create_internal_tmp_table_from_heap(THD*, st_table*, st_maria_columndef*, st_maria_columndef**, int, bool) (sql_select.cc:14287)
==2976==
==2976== Conditional jump or move depends on uninitialised value(s)
==2976== at 0x87BAACB: strnmov (in /home/philips/bzr/maria-5.3/sql/mysqld)
==2976== by 0x87D3AE7: my_vsnprintf_ex (my_vsnprintf.c:567)
==2976== by 0x87D3CE7: my_vsnprintf (my_vsnprintf.c:624)
==2976== by 0x854F7CD: _ma_check_print_msg(st_handler_check_param*, char const*, char const*, char*) (ha_maria.cc:306)
==2976== by 0x85511FA: _ma_check_print_warning (ha_maria.cc:784)
==2976== by 0x85C985E: sort_key_write (ma_check.c:5503)
==2976== by 0x860BD14: write_index (ma_sort.c:772)
==2976== by 0x8609DB6: _ma_create_index_by_sort (ma_sort.c:201)
==2976== by 0x85C433F: maria_repair_by_sort (ma_check.c:3877)
==2976== by 0x8553E30: ha_maria::repair(THD*, st_handler_check_param*, bool) (ha_maria.cc:1620)
==2976== by 0x8554B5B: ha_maria::enable_indexes(unsigned int) (ha_maria.cc:1946)
==2976== by 0x855536B: ha_maria::end_bulk_insert() (ha_maria.cc:2135)
==2976== by 0x834E7FC: handler::ha_end_bulk_insert() (handler.h:1778)
==2976== by 0x833CABB: create_internal_tmp_table_from_heap2(THD*, st_table*, st_maria_columndef*, st_maria_columndef**, int, bool, handlerton*, char const*
) (sql_select.cc:14540)
==2976== by 0x833C67...

Read more...

Changed in maria:
status: New → Confirmed
importance: Undecided → High
Revision history for this message
Igor Babaev (igorb-seattle) wrote :

This problem is observed due to the fact that the current code does not support conversion of an internal temporary table into maria/myisam table in the case when we have either one non-unique key defined for the internal temporary table, or several keys defined for an internal temporary table.
I assign the bug to Monty requesting to support these cases.

Changed in maria:
assignee: Igor Babaev (igorb-seattle) → Michael Widenius (monty)
Revision history for this message
Igor Babaev (igorb-seattle) wrote :

Monty,
It will be enough now to support only the case when an internal temporary table can be accessed only by one non-unique key, because now a materialized derived table/view is accessed only by one key at best.

Michael Widenius (monty)
Changed in maria:
status: Confirmed → In Progress
Revision history for this message
Michael Widenius (monty) wrote :

I have now fixed so that when converting a temporary table to a Aria / MyISAM table, we honor the unique status of the original key.
Multiple keys is not supported (we don't need it yet)

Changed in maria:
status: In Progress → Fix Committed
Michael Widenius (monty)
Changed in maria:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.