Server crashes in _mi_put_key_in_record on KILL QUERY with ICP, STRAIGHT_JOIN

Bug #933412 reported by Elena Stepanova on 2012-02-16
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
MariaDB
Fix Released
Undecided
Sergey Petrunia

Bug Description

#4 <signal handler called>
#5 0x0854c0cc in _mi_put_key_in_record (info=0x94be0b8, keynr=0, unpack_blobs=0 '\000',
    record=0x0) at mi_key.c:410
#6 0x0854c3ee in mi_check_index_cond (info=0x94be0b8, keynr=0, record=0x0) at mi_key.c:517
#7 0x0855293b in mi_rkey (info=0x94be0b8, buf=0x0, inx=0, key=0x945f078 "\001", keypart_map=1,
    search_flag=HA_READ_KEY_EXACT) at mi_rkey.c:121
#8 0x0851b764 in ha_myisam::index_read_map (this=0x947e8c8, buf=0x947edc0 "\374\006",
    key=0x945f078 "\001", keypart_map=1, find_flag=HA_READ_KEY_EXACT) at ha_myisam.cc:1813
#9 0x081eccd6 in handler::ha_index_read_map (this=0x947e8c8, buf=0x947edc0 "\374\006",
    key=0x945f078 "\001", keypart_map=1, find_flag=HA_READ_KEY_EXACT) at sql_class.h:3654
#10 0x08376994 in join_read_always_key (tab=0x94b7f58) at sql_select.cc:16058
#11 0x083751b3 in sub_select (join=0x94738f8, join_tab=0x94b7f58, end_of_records=false)
    at sql_select.cc:15373
#12 0x083758a2 in evaluate_join_record (join=0x94738f8, join_tab=0x94b7d50, error=0)
    at sql_select.cc:15573
#13 0x08375350 in sub_select (join=0x94738f8, join_tab=0x94b7d50, end_of_records=false)
    at sql_select.cc:15416
#14 0x08374a5b in do_select (join=0x94738f8, fields=0x93f05b4, table=0x0, procedure=0x0)
    at sql_select.cc:15037
#15 0x08358c65 in JOIN::exec (this=0x94738f8) at sql_select.cc:2710
#16 0x08359495 in mysql_select (thd=0x93eead0, rref_pointer_array=0x93f065c, tables=0x945d428,
    wild_num=1, fields=..., conds=0x945df48, og_num=0, order=0x0, group=0x0, having=0x0,
    proc_param=0x0, select_options=2147764736, result=0x945e0b0, unit=0x93f0240,
    select_lex=0x93f0520) at sql_select.cc:2931
#17 0x083511af in handle_select (thd=0x93eead0, lex=0x93f01e4, result=0x945e0b0,
    setup_tables_done_option=0) at sql_select.cc:284
#18 0x082ec3b9 in execute_sqlcom_select (thd=0x93eead0, all_tables=0x945d428) at sql_parse.cc:5151
#19 0x082e3795 in mysql_execute_command (thd=0x93eead0) at sql_parse.cc:2284
#20 0x082ee9f4 in mysql_parse (thd=0x93eead0,
    rawbuf=0x945d240 "SELECT * FROM t1 AS alias1 STRAIGHT_JOIN t1 AS alias2\nON alias2.c = alias1.c\nWHERE alias2.b >= 9", length=96, found_semicolon=0xae888234) at sql_parse.cc:6152
#21 0x082e13d5 in dispatch_command (command=COM_QUERY, thd=0x93eead0, packet=0x9447941 "",
    packet_length=96) at sql_parse.cc:1228
#22 0x082e087f in do_command (thd=0x93eead0) at sql_parse.cc:923
#23 0x082dd805 in handle_one_connection (arg=0x93eead0) at sql_connect.cc:1193
#24 0xb769db25 in start_thread () from /lib/libpthread.so.0

bzr version-info
revision-id: <email address hidden>
date: 2012-02-14 16:52:56 +0200
build-date: 2012-02-16 15:57:13 +0400
revno: 3421

Also reproducible on MariaDB 5.5.

EXPLAIN:

id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE alias1 ALL c NULL NULL NULL 157 100.00
1 SIMPLE alias2 ref c c 3 test.alias1.c 6 100.00 Using index condition
Warnings:
Note 1003 select `test`.`alias1`.`b` AS `b`,`test`.`alias1`.`c` AS `c`,`test`.`alias1`.`d` AS `d`,`test`.`alias2`.`b` AS `b`,`test`.`alias2`.`c` AS `c`,`test`.`alias2`.`d` AS `d` from `test`.`t1` `alias1` straight_join `test`.`t1` `alias2` where ((`test`.`alias2`.`c` = `test`.`alias1`.`c`) and (`test`.`alias2`.`b` >= 9))

Minimal optimizer_switch: index_condition_pushdown=on
Full optimizer_switch (current default): index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=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

Test case:

# Please note that there is a race condition involved, so the test case attempts to run and kill the query several times. The number of attempts is set in $run variable.

SET optimizer_switch='index_condition_pushdown=on';

CREATE TABLE t1 (
  b INT,
  c VARCHAR(1) NOT NULL,
  d DATETIME,
  KEY (c, b)
) ENGINE=MyISAM;
INSERT INTO t1 ( b, d, c ) VALUES
(4,'2005-01-08 00:00:00','f'),
(1,'2004-05-20 10:45:51','c'),(2,'2006-08-11 21:33:49','e'),
(5,'2003-05-19 00:20:40','a'),(3,'2005-01-03 06:18:39','a'),
(7,'2008-11-25 18:18:14','b'),(6,'2008-11-09 15:53:46','b'),
(9,'2003-03-01 03:40:36','c'),(8,'2003-09-25 23:14:09','d'),
(0,'2007-01-17 09:18:31','f'),(9,'2008-09-08 09:52:24','c'),
(2,'2008-03-10 00:00:00','a'),(0,'2003-03-14 09:31:07','c'),
(4,'2005-04-25 00:00:00','h'),(6,'2001-08-01 05:55:55','e'),
(3,'2005-04-09 01:22:48','f'),(7,'2009-11-12 13:27:22','r'),
(0,'2009-03-28 05:05:28','h'),(15,'2005-05-16 04:35:41','f'),
(7,'2006-03-26 05:19:58','c'),(9,'2002-10-06 02:17:00','g'),
(4,'2007-01-28 03:28:20','b'),(1,'2009-04-22 10:16:40','c'),
(2,'2003-01-01 19:39:00','f'),(0,'2008-05-03 19:16:29','t'),
(2,'2005-01-28 00:00:00','j'),(8,'2004-01-10 00:00:00','w'),
(8,'2000-06-13 21:56:37','a'),(5,'2001-03-21 19:24:49','o'),
(99,'2003-12-20 21:29:06','f'),(0,'1900-01-01 00:00:00','w'),
(7,'2000-12-19 00:00:00','c'),(0,'2000-03-03 06:10:19','l'),
(3,'2000-08-11 00:00:00','q'),(0,'2007-05-25 03:46:41','e'),
(241,'2005-05-17 00:00:00','j'),(4,'2005-11-02 00:44:06','r'),
(43,'2001-07-11 00:00:00','a'),(1,'2008-12-01 18:30:27','z'),
(4,'2004-10-25 00:00:00','i'),(5,'2000-04-08 12:12:01','c'),
(0,'1900-01-01 00:00:00','f'),(9,'2002-05-13 22:47:02','p'),
(1,'2008-10-09 15:39:40','d'),(3,'2004-06-24 00:00:00','d'),
(0,'2008-03-06 00:00:00','r'),(9,'2007-04-16 18:40:03','i'),
(3,'2008-03-16 19:49:37','t'),(7,'2003-07-15 08:11:21','d'),
(8,'2005-02-11 00:04:53','r'),(0,'2002-09-21 00:00:00','y'),
(3,'2004-11-03 00:37:21','z'),(6,'2007-10-18 00:00:00','e'),
(6,'2007-01-21 10:42:56','o'),(5,'2000-03-26 21:21:04','b'),
(9,'2001-03-15 08:08:21','e'),(1,'2001-10-16 12:56:59','a'),
(6,'2004-05-01 23:45:55','o'),(4,'2000-03-04 00:00:00','f'),
(9,'2002-12-03 16:48:28','e'),(8,'2003-01-09 00:36:07','m'),
(1,'2006-06-22 04:32:41','s'),(8,'2008-09-20 05:01:48','q'),
(4,'2006-06-02 22:15:31','g'),(2,'2002-05-14 07:07:42','e'),
(7,'2005-06-05 01:30:42','r'),(127,'2004-05-11 01:56:48','a'),
(210,'2003-11-05 00:41:34','z'),(5,'1900-01-01 00:00:00','h'),
(1,'2006-04-16 00:00:00','f'),(7,'2000-12-17 00:00:00','x'),
(8,'2009-05-09 20:43:07','b'),(175,'2008-11-26 16:33:09','p'),
(0,'2002-05-09 21:18:44','v'),(8,'2002-06-01 11:32:25','k'),
(1,'2008-11-09 23:56:00','a'),(0,'2008-01-08 10:18:46','c'),
(2,'2005-04-16 00:00:00','o'),(5,'2002-08-25 00:00:00','b'),
(64,'2005-12-05 21:51:52','b'),(4,'2005-08-10 00:00:00','i'),
(6,'2006-03-23 00:00:00','d'),(9,'2007-01-27 00:00:00','i'),
(8,'2008-08-16 00:00:00','a'),(7,'2003-01-16 12:13:18','k'),
(0,'2003-06-22 00:00:00','v'),(5,'2008-06-20 05:43:56','u'),
(8,'2004-09-23 18:57:17','e'),(1,'2000-12-26 00:00:00','y'),
(4,'2009-06-01 13:00:28','e'),(1,'2009-11-18 06:28:48','m'),
(0,'2004-06-12 10:01:10','e'),(2,'2005-10-16 01:48:55','e'),
(5,'2001-12-23 09:50:21','l'),(6,'1900-01-01 00:00:00','a'),
(1,'2001-10-28 00:00:00','d'),(1,'2008-07-12 23:30:19','s'),
(0,'2002-10-11 16:51:16','r'),(4,'2007-09-18 06:27:10','x'),
(1,'2007-02-21 12:28:14','e'),(6,'2001-09-16 00:00:00','f'),
(0,'2007-09-20 02:25:45','c'),(0,'2006-08-07 03:25:56','j'),
(8,'2006-12-04 20:20:32','t'),(7,'2007-09-05 10:13:10','i'),
(9,'2006-04-12 17:59:57','t'),(2,'2009-04-28 00:06:09','b'),
(8,'2000-01-07 00:00:00','b'),(7,'2000-03-25 10:04:41','k'),
(4,'2000-07-10 00:44:55','w'),(9,'2007-09-22 14:26:26','j'),
(9,'2003-09-11 22:41:17','a'),(0,'2004-06-07 13:52:32','c'),
(8,'2008-10-09 00:00:00','p'),(1,'2007-04-01 00:00:00','c'),
(9,'2000-12-05 00:00:00','i'),(3,'1900-01-01 00:00:00','a'),
(3,'2005-12-24 21:50:54','e'),(8,'2009-07-21 19:34:55','n'),
(9,'2005-11-13 17:57:56','d'),(7,'2004-10-07 06:41:39','l'),
(1,'2004-11-20 08:05:08','u'),(3,'2005-05-25 00:00:00','r'),
(1,'2006-09-02 14:16:41','u'),(8,'2006-01-07 00:00:00','a'),
(9,'2003-04-05 00:54:20','w'),(2,'2003-12-22 00:00:00','a'),
(9,'2006-04-16 17:31:40','e'),(6,'2005-02-10 14:22:46','e'),
(7,'2004-04-27 05:54:52','p'),(1,'2005-12-07 00:00:00','t'),
(5,'2004-04-03 20:56:28','d'),(4,'2000-09-07 05:17:16','h'),
(2,'2004-08-04 16:10:42','i'),(1,'2007-03-04 00:00:00','b'),
(9,'1900-01-01 00:00:00','d'),(1,'2000-05-12 23:02:50','m'),
(2,'1900-01-01 00:00:00','l'),(1,'1900-01-01 00:00:00','k'),
(4,'2000-07-14 01:25:18','d'),(5,'2009-08-21 00:00:00','w'),
(6,'2009-05-25 13:33:54','f'),(7,'2006-06-13 00:00:00','e'),
(8,'1900-01-01 00:00:00','a'),(6,'2004-02-24 00:00:00','j'),
(0,'2003-05-21 07:03:46','k'),(9,'1900-01-01 00:00:00','e'),
(2,'1900-01-01 00:00:00','y'),(2,'2000-12-22 00:00:00','e'),
(3,'2003-09-26 00:00:00','f'),(2,'2001-01-13 08:20:19','h'),
(9,'2008-09-23 20:03:28','n'),(5,'2007-03-20 02:41:38','s'),
(1,'2009-02-14 10:27:18','a'),(0,'2001-08-10 17:44:05','s'),
(3,'2008-01-20 12:49:54','v'),(1,'2001-05-05 09:09:59','r');

CREATE TABLE t2 ( a INT ) ENGINE=MyISAM;
INSERT INTO t2 VALUES
  (7),(3),(7),(3);

--let $run = 100
--let $con_id = `SELECT CONNECTION_ID()`

while ($run)
{
  --send
    SELECT * FROM t1 AS alias1 STRAIGHT_JOIN t1 AS alias2
        ON alias2.c = alias1.c
        WHERE alias2.b >= 9;

  --connect (con1,127.0.0.1,root,,test)
  --eval KILL QUERY $con_id
  --disconnect con1

  --dec $run

  --connection default
  --error ER_QUERY_INTERRUPTED
  --reap
}

# End of test case

Elena Stepanova (elenst) on 2012-02-16
description: updated
Changed in maria:
status: New → Confirmed
status: Confirmed → In Progress
Changed in maria:
status: In Progress → Fix Committed
status: Fix Committed → In Progress
Changed in maria:
status: In Progress → Fix Committed
Elena Stepanova (elenst) wrote :

Fix released with 5.3.5-ga.

Changed in maria:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers