Skip to content

Commit 6f97ee3

Browse files
committed
MDEV-30651: Assertion `sel->quick' in make_range_rowid_filters
(Variant for 10.6: return error code from SQL_SELECT::test_quick_select) The optimizer deals with Rowid Filters this way: 1. First, range optimizer is invoked. It saves information about all potential range accesses. 2. A query plan is chosen. Suppose, it uses a Rowid Filter on index $IDX. 3. JOIN::make_range_rowid_filters() calls the range optimizer again to create a quick select on index $IDX which will be used to populate the rowid filter. The problem: KILL command catches the query in step #3. Quick Select is not created which causes a crash. Fixed by checking if query was killed.
1 parent 32202c3 commit 6f97ee3

File tree

5 files changed

+73
-3
lines changed

5 files changed

+73
-3
lines changed

mysql-test/include/rowid_filter_debug_kill.inc

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,33 @@ disconnect con1;
5555
reap;
5656
set debug_sync='RESET';
5757

58+
--echo #
59+
--echo # MDEV-30651: SIGSEGV in st_join_table::save_explain_data and
60+
--echo # Assertion `sel->quick' failed in make_range_rowid_filters
61+
--echo #
62+
63+
--echo # Reusing table t2 and t3 from previous test
64+
let $target_id= `select connection_id()`;
65+
66+
set debug_sync='in_forced_range_optimize SIGNAL ready1 WAIT_FOR go1';
67+
send
68+
explain
69+
select * from t2, t3
70+
where
71+
t3.key1=t2.a and t3.key2 in (2,3);
72+
73+
connect (con1, localhost, root,,);
74+
set debug_sync='now WAIT_FOR ready1';
75+
evalp kill query $target_id;
76+
set debug_sync='now SIGNAL go1';
77+
78+
connection default;
79+
disconnect con1;
80+
81+
--error ER_QUERY_INTERRUPTED
82+
reap;
83+
set debug_sync='RESET';
84+
85+
5886
drop table t2,t3;
5987
--source include/wait_until_count_sessions.inc

mysql-test/main/rowid_filter_innodb_debug.result

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,23 @@ connection default;
4646
disconnect con1;
4747
ERROR 70100: Query execution was interrupted
4848
set debug_sync='RESET';
49+
#
50+
# MDEV-30651: SIGSEGV in st_join_table::save_explain_data and
51+
# Assertion `sel->quick' failed in make_range_rowid_filters
52+
#
53+
# Reusing table t2 and t3 from previous test
54+
set debug_sync='in_forced_range_optimize SIGNAL ready1 WAIT_FOR go1';
55+
explain
56+
select * from t2, t3
57+
where
58+
t3.key1=t2.a and t3.key2 in (2,3);
59+
connect con1, localhost, root,,;
60+
set debug_sync='now WAIT_FOR ready1';
61+
kill query $target_id;
62+
set debug_sync='now SIGNAL go1';
63+
connection default;
64+
disconnect con1;
65+
ERROR 70100: Query execution was interrupted
66+
set debug_sync='RESET';
4967
drop table t2,t3;
5068
set default_storage_engine=default;

mysql-test/main/rowid_filter_myisam_debug.result

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,22 @@ connection default;
4545
disconnect con1;
4646
ERROR 70100: Query execution was interrupted
4747
set debug_sync='RESET';
48+
#
49+
# MDEV-30651: SIGSEGV in st_join_table::save_explain_data and
50+
# Assertion `sel->quick' failed in make_range_rowid_filters
51+
#
52+
# Reusing table t2 and t3 from previous test
53+
set debug_sync='in_forced_range_optimize SIGNAL ready1 WAIT_FOR go1';
54+
explain
55+
select * from t2, t3
56+
where
57+
t3.key1=t2.a and t3.key2 in (2,3);
58+
connect con1, localhost, root,,;
59+
set debug_sync='now WAIT_FOR ready1';
60+
kill query $target_id;
61+
set debug_sync='now SIGNAL go1';
62+
connection default;
63+
disconnect con1;
64+
ERROR 70100: Query execution was interrupted
65+
set debug_sync='RESET';
4866
drop table t2,t3;

sql/opt_range.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2720,7 +2720,10 @@ SQL_SELECT::test_quick_select(THD *thd,
27202720
only_single_index_range_scan= 1;
27212721

27222722
if (head->force_index || force_quick_range)
2723+
{
2724+
DEBUG_SYNC(thd, "in_forced_range_optimize");
27232725
scan_time= read_time= DBL_MAX;
2726+
}
27242727
else
27252728
{
27262729
scan_time= rows2double(records) / TIME_FOR_COMPARE;
@@ -3117,6 +3120,8 @@ SQL_SELECT::test_quick_select(THD *thd,
31173120
free_root(&alloc,MYF(0)); // Return memory & allocator
31183121
thd->mem_root= param.old_root;
31193122
thd->no_errors=0;
3123+
if (param.statement_should_be_aborted())
3124+
returnval= ERROR;
31203125
}
31213126

31223127
DBUG_EXECUTE("info", print_quick(quick, &needed_reg););

sql/sql_select.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1987,6 +1987,7 @@ bool JOIN::make_range_rowid_filters()
19871987
tab->table->force_index= force_index_save;
19881988
if (rc == SQL_SELECT::ERROR || thd->is_error())
19891989
{
1990+
delete sel;
19901991
DBUG_RETURN(true); /* Fatal error */
19911992
}
19921993
/*
@@ -2012,8 +2013,6 @@ bool JOIN::make_range_rowid_filters()
20122013
continue;
20132014
}
20142015
no_filter:
2015-
if (sel->quick)
2016-
delete sel->quick;
20172016
delete sel;
20182017
}
20192018

@@ -2031,7 +2030,9 @@ bool JOIN::make_range_rowid_filters()
20312030
rowid container employed by the filter. On success it lets the table engine
20322031
know that what rowid filter will be used when accessing the table rows.
20332032

2034-
@retval false always
2033+
@retval
2034+
false OK
2035+
true Error, query should abort
20352036
*/
20362037

20372038
bool

0 commit comments

Comments
 (0)