Skip to content

Commit 171da6b

Browse files
grooverdanspetrunia
authored andcommitted
MDEV-22761: innodb row_search_idx_cond_check handle CHECK_ABORTED_BY_USER
handler_rowid_filter_check can return CHECK_ABORTED_BY_USER. All the functions that call row_search_idx_cond_check handle the CHECK_ABORTED_BY_USER return value. So return it rather than generating an error. This incorrect handling was introduced in MDEV-21794 (8d85715). Reviewer: Marko Mäkelä
1 parent 5896a49 commit 171da6b

File tree

4 files changed

+77
-2
lines changed

4 files changed

+77
-2
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
set @save_optimizer_switch= @@optimizer_switch;
2+
set @save_use_stat_tables= @@use_stat_tables;
3+
set @save_optimizer_use_condition_selectivity= @@optimizer_use_condition_selectivity;
4+
set @@use_stat_tables=preferably;
5+
set optimizer_use_condition_selectivity=2;
6+
set optimizer_switch='rowid_filter=on';
7+
#
8+
# MDEV-22761 KILL QUERY during rowid_filter, crashes
9+
#
10+
CREATE TABLE t1 (a INT, b INT, INDEX(a), INDEX(b)) ENGINE=InnoDB;
11+
INSERT INTO t1 VALUES (0,0),(1,0),(-1,1), (-2,1), (-2,3), (-3,4), (-2,4);
12+
set debug_sync='row_search_pre_rowid_filter_check SIGNAL killme WAIT_FOR go';
13+
SELECT * FROM t1 WHERE a > 0 AND b=0;
14+
connect con1, localhost, root,,;
15+
connection con1;
16+
set debug_sync='now WAIT_FOR killme';
17+
kill query @id;
18+
set debug_sync='now SIGNAL go';
19+
connection default;
20+
a b
21+
set debug_sync='RESET';
22+
disconnect con1;
23+
drop table t1;
24+
set @@optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
25+
set @@optimizer_switch=@save_optimizer_switch;
26+
set @@use_stat_tables=@save_use_stat_tables;
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
--source include/have_debug.inc
2+
--source include/have_debug_sync.inc
3+
--source include/have_innodb.inc
4+
--source include/default_optimizer_switch.inc
5+
--source include/count_sessions.inc
6+
7+
set @save_optimizer_switch= @@optimizer_switch;
8+
set @save_use_stat_tables= @@use_stat_tables;
9+
set @save_optimizer_use_condition_selectivity= @@optimizer_use_condition_selectivity;
10+
11+
set @@use_stat_tables=preferably;
12+
13+
set optimizer_use_condition_selectivity=2;
14+
set optimizer_switch='rowid_filter=on';
15+
16+
--echo #
17+
--echo # MDEV-22761 KILL QUERY during rowid_filter, crashes
18+
--echo #
19+
20+
CREATE TABLE t1 (a INT, b INT, INDEX(a), INDEX(b)) ENGINE=InnoDB;
21+
INSERT INTO t1 VALUES (0,0),(1,0),(-1,1), (-2,1), (-2,3), (-3,4), (-2,4);
22+
23+
let $ID= `SELECT @id := CONNECTION_ID()`;
24+
25+
set debug_sync='row_search_pre_rowid_filter_check SIGNAL killme WAIT_FOR go';
26+
send SELECT * FROM t1 WHERE a > 0 AND b=0;
27+
28+
connect (con1, localhost, root,,);
29+
connection con1;
30+
let $ignore= `SELECT @id := $ID`;
31+
set debug_sync='now WAIT_FOR killme';
32+
kill query @id;
33+
set debug_sync='now SIGNAL go';
34+
35+
connection default;
36+
reap;
37+
set debug_sync='RESET';
38+
39+
disconnect con1;
40+
drop table t1;
41+
42+
set @@optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
43+
set @@optimizer_switch=@save_optimizer_switch;
44+
set @@use_stat_tables=@save_use_stat_tables;
45+
46+
--source include/wait_until_count_sessions.inc

mysql-test/unstable-tests

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ main.rowid_filter : Modified in 10.4.13
184184
main.rowid_filter_innodb : MDEV-20538 - Wrong result; modified in 10.4.13
185185
main.rowid_filter_myisam : Added in 10.4.14
186186
main.rpl_mysql_upgrade_slave_repo_check : Added in 10.4.13
187+
main.rowid_filter_innodb_debug : MDEV-22761 - Added in 10.4.15
187188
main.select : MDEV-20532 - Floating point differences
188189
main.select_jcl6 : MDEV-20532 - Floating point differences
189190
main.select_pkeycache : MDEV-20532 - Floating point differences

storage/innobase/row/row0sel.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3900,7 +3900,7 @@ row_sel_try_search_shortcut_for_mysql(
39003900

39013901
/*********************************************************************//**
39023902
Check a pushed-down index condition.
3903-
@return CHECK_NEG, CHECK_POS, or CHECK_OUT_OF_RANGE */
3903+
@return CHECK_ABORTED_BY_USER, CHECK_NEG, CHECK_POS, or CHECK_OUT_OF_RANGE */
39043904
static
39053905
check_result_t
39063906
row_search_idx_cond_check(
@@ -3975,6 +3975,8 @@ row_search_idx_cond_check(
39753975
ut_ad(len == DATA_ROW_ID_LEN);
39763976
memcpy(prebuilt->row_id, data, DATA_ROW_ID_LEN);
39773977
}
3978+
DEBUG_SYNC_C("row_search_pre_rowid_filter_check");
3979+
39783980
result = handler_rowid_filter_check(prebuilt->pk_filter);
39793981
switch (result) {
39803982
case CHECK_NEG:
@@ -3986,7 +3988,7 @@ row_search_idx_cond_check(
39863988
case CHECK_POS:
39873989
break;
39883990
default:
3989-
ut_error;
3991+
return(result);
39903992
}
39913993
}
39923994
/* Convert the remaining fields to MySQL format.

0 commit comments

Comments
 (0)