Skip to content

Commit

Permalink
MDEV-22761: innodb row_search_idx_cond_check handle CHECK_ABORTED_BY_…
Browse files Browse the repository at this point in the history
…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ä
  • Loading branch information
grooverdan committed Oct 6, 2020
1 parent bd64c2e commit e8b9afa
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 2 deletions.
26 changes: 26 additions & 0 deletions mysql-test/main/rowid_filter_innodb_debug.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
set @save_optimizer_switch= @@optimizer_switch;
set @save_use_stat_tables= @@use_stat_tables;
set @save_optimizer_use_condition_selectivity= @@optimizer_use_condition_selectivity;
set @@use_stat_tables=preferably;
set optimizer_use_condition_selectivity=2;
set optimizer_switch='rowid_filter=on';
#
# MDEV-22761 KILL QUERY during rowid_filter, crashes
#
CREATE TABLE t1 (a INT, b INT, INDEX(a), INDEX(b)) ENGINE=InnoDB;
INSERT INTO t1 VALUES (0,0),(1,0),(-1,1), (-2,1), (-2,3), (-3,4), (-2,4);
set debug_sync='row_search_pre_rowid_filter_check SIGNAL killme WAIT_FOR go';
SELECT * FROM t1 WHERE a > 0 AND b=0;
connect con1, localhost, root,,;
connection con1;
set debug_sync='now WAIT_FOR killme';
kill query @id;
set debug_sync='now SIGNAL go';
connection default;
a b
set debug_sync='RESET';
disconnect con1;
drop table t1;
set @@optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
set @@optimizer_switch=@save_optimizer_switch;
set @@use_stat_tables=@save_use_stat_tables;
46 changes: 46 additions & 0 deletions mysql-test/main/rowid_filter_innodb_debug.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
--source include/have_debug.inc
--source include/have_debug_sync.inc
--source include/have_innodb.inc
--source include/default_optimizer_switch.inc
--source include/count_sessions.inc

set @save_optimizer_switch= @@optimizer_switch;
set @save_use_stat_tables= @@use_stat_tables;
set @save_optimizer_use_condition_selectivity= @@optimizer_use_condition_selectivity;

set @@use_stat_tables=preferably;

set optimizer_use_condition_selectivity=2;
set optimizer_switch='rowid_filter=on';

--echo #
--echo # MDEV-22761 KILL QUERY during rowid_filter, crashes
--echo #

CREATE TABLE t1 (a INT, b INT, INDEX(a), INDEX(b)) ENGINE=InnoDB;
INSERT INTO t1 VALUES (0,0),(1,0),(-1,1), (-2,1), (-2,3), (-3,4), (-2,4);

let $ID= `SELECT @id := CONNECTION_ID()`;

set debug_sync='row_search_pre_rowid_filter_check SIGNAL killme WAIT_FOR go';
send SELECT * FROM t1 WHERE a > 0 AND b=0;

connect (con1, localhost, root,,);
connection con1;
let $ignore= `SELECT @id := $ID`;
set debug_sync='now WAIT_FOR killme';
kill query @id;
set debug_sync='now SIGNAL go';

connection default;
reap;
set debug_sync='RESET';

disconnect con1;
drop table t1;

set @@optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
set @@optimizer_switch=@save_optimizer_switch;
set @@use_stat_tables=@save_use_stat_tables;

--source include/wait_until_count_sessions.inc
1 change: 1 addition & 0 deletions mysql-test/unstable-tests
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ main.rowid_filter : Modified in 10.4.13
main.rowid_filter_innodb : MDEV-20538 - Wrong result; modified in 10.4.13
main.rowid_filter_myisam : Added in 10.4.14
main.rpl_mysql_upgrade_slave_repo_check : Added in 10.4.13
main.rowid_filter_innodb_debug : MDEV-22761 - Added in 10.4.15
main.select : MDEV-20532 - Floating point differences
main.select_jcl6 : MDEV-20532 - Floating point differences
main.select_pkeycache : MDEV-20532 - Floating point differences
Expand Down
6 changes: 4 additions & 2 deletions storage/innobase/row/row0sel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3900,7 +3900,7 @@ row_sel_try_search_shortcut_for_mysql(

/*********************************************************************//**
Check a pushed-down index condition.
@return CHECK_NEG, CHECK_POS, or CHECK_OUT_OF_RANGE */
@return CHECK_ABORTED_BY_USER, CHECK_NEG, CHECK_POS, or CHECK_OUT_OF_RANGE */
static
check_result_t
row_search_idx_cond_check(
Expand Down Expand Up @@ -3975,6 +3975,8 @@ row_search_idx_cond_check(
ut_ad(len == DATA_ROW_ID_LEN);
memcpy(prebuilt->row_id, data, DATA_ROW_ID_LEN);
}
DEBUG_SYNC_C("row_search_pre_rowid_filter_check");

result = handler_rowid_filter_check(prebuilt->pk_filter);
switch (result) {
case CHECK_NEG:
Expand All @@ -3986,7 +3988,7 @@ row_search_idx_cond_check(
case CHECK_POS:
break;
default:
ut_error;
return(result);
}
}
/* Convert the remaining fields to MySQL format.
Expand Down

0 comments on commit e8b9afa

Please sign in to comment.