Skip to content

Commit e206c0c

Browse files
committed
MDEV-22761: innodb row_search_idx_cond_check handle CHECK_ABORTED_BY_USER
Part #2: - row_search_mvcc() should return DB_INTERRUPTED when it got - Move the sync point from innodb internals to handler_rowid_filter_check() where other storage engines can use it too - Add a similar syncpoint for the ICP check. - Add a bigger test and test coverage for Rowid Filter with MyISAM - Add test coverage for killed-during-ICP-check scenario
1 parent e8b9afa commit e206c0c

14 files changed

+359
-8
lines changed

mysql-test/include/icp_debug_kill.inc

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
--source include/have_debug.inc
2+
--source include/have_debug_sync.inc
3+
--source include/count_sessions.inc
4+
5+
--disable_warnings
6+
drop table if exists t0,t1,t2;
7+
--enable_warnings
8+
9+
create table t0(a int primary key);
10+
insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
11+
12+
create table t1(a int primary key);
13+
insert into t1 select A.a + B.a* 10 + C.a * 100 from t0 A, t0 B, t0 C;
14+
15+
create table t2 (
16+
kp1 int,
17+
kp2 int,
18+
col char(100),
19+
key(kp1, kp2)
20+
);
21+
insert into t2 select a, a, a from t1;
22+
23+
select engine from information_schema.tables
24+
where table_schema=database() and table_name='t2';
25+
26+
explain
27+
select * from t2 where kp1 between 10 and 20 and kp2 +1 >100;
28+
29+
let $target_id= `select connection_id()`;
30+
31+
set debug_sync='handler_index_cond_check SIGNAL at_icp_check WAIT_FOR go';
32+
send
33+
select * from t2 where kp1 between 10 and 20 and kp2 +1 >100;
34+
35+
connect (con1, localhost, root,,);
36+
connection con1;
37+
set debug_sync='now WAIT_FOR at_icp_check';
38+
evalp kill query $target_id;
39+
set debug_sync='now SIGNAL go';
40+
41+
connection default;
42+
43+
--error ER_QUERY_INTERRUPTED
44+
reap;
45+
set debug_sync='RESET';
46+
47+
disconnect con1;
48+
drop table t0,t1,t2;
49+
--source include/wait_until_count_sessions.inc
50+
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
--source include/have_debug.inc
2+
--source include/have_debug_sync.inc
3+
--source include/count_sessions.inc
4+
5+
--echo #
6+
--echo # MDEV-22761 KILL QUERY during rowid_filter, crashes
7+
--echo #
8+
9+
create table t0(a int);
10+
insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
11+
12+
create table t1(a int);
13+
insert into t1 select A.a + B.a* 10 + C.a * 100 from t0 A, t0 B, t0 C;
14+
15+
# 100 rows
16+
create table t2(a int);
17+
insert into t2 select A.a + B.a* 10 from t0 A, t0 B;
18+
19+
# 10K rows
20+
CREATE TABLE t3 (
21+
key1 int ,
22+
key2 int,
23+
filler varchar(255),
24+
KEY (key1),
25+
KEY (key2)
26+
);
27+
select engine from information_schema.tables
28+
where table_schema=database() and table_name='t3';
29+
30+
insert into t3
31+
select
32+
A.a,
33+
A.a,
34+
'filler-data-filler-data'
35+
from
36+
t0 A, t1 B;
37+
38+
analyze table t2,t3;
39+
40+
explain
41+
select * from t2, t3
42+
where
43+
t3.key1=t2.a and t3.key2 in (2,3);
44+
45+
let $target_id= `select connection_id()`;
46+
47+
set debug_sync='handler_rowid_filter_check SIGNAL at_rowid_filter_check WAIT_FOR go';
48+
send
49+
select * from t2, t3
50+
where
51+
t3.key1=t2.a and t3.key2 in (2,3);
52+
53+
connect (con1, localhost, root,,);
54+
connection con1;
55+
set debug_sync='now WAIT_FOR at_rowid_filter_check';
56+
evalp kill query $target_id;
57+
set debug_sync='now SIGNAL go';
58+
59+
connection default;
60+
disconnect con1;
61+
62+
--error ER_QUERY_INTERRUPTED
63+
reap;
64+
set debug_sync='RESET';
65+
66+
drop table t0,t1,t2,t3;
67+
--source include/wait_until_count_sessions.inc
68+

mysql-test/main/aria_icp_debug.result

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
set default_storage_engine=aria;
2+
drop table if exists t0,t1,t2;
3+
create table t0(a int primary key);
4+
insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
5+
create table t1(a int primary key);
6+
insert into t1 select A.a + B.a* 10 + C.a * 100 from t0 A, t0 B, t0 C;
7+
create table t2 (
8+
kp1 int,
9+
kp2 int,
10+
col char(100),
11+
key(kp1, kp2)
12+
);
13+
insert into t2 select a, a, a from t1;
14+
select engine from information_schema.tables
15+
where table_schema=database() and table_name='t2';
16+
engine
17+
Aria
18+
explain
19+
select * from t2 where kp1 between 10 and 20 and kp2 +1 >100;
20+
id select_type table type possible_keys key key_len ref rows Extra
21+
1 SIMPLE t2 range kp1 kp1 5 NULL 10 Using index condition
22+
set debug_sync='handler_index_cond_check SIGNAL at_icp_check WAIT_FOR go';
23+
select * from t2 where kp1 between 10 and 20 and kp2 +1 >100;
24+
connect con1, localhost, root,,;
25+
connection con1;
26+
set debug_sync='now WAIT_FOR at_icp_check';
27+
kill query $target_id;
28+
set debug_sync='now SIGNAL go';
29+
connection default;
30+
ERROR 70100: Query execution was interrupted
31+
set debug_sync='RESET';
32+
disconnect con1;
33+
drop table t0,t1,t2;
34+
set default_storage_engine=default;

mysql-test/main/aria_icp_debug.test

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
set default_storage_engine=aria;
3+
--source include/icp_debug_kill.inc
4+
set default_storage_engine=default;
5+
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
set default_storage_engine=innodb;
2+
drop table if exists t0,t1,t2;
3+
create table t0(a int primary key);
4+
insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
5+
create table t1(a int primary key);
6+
insert into t1 select A.a + B.a* 10 + C.a * 100 from t0 A, t0 B, t0 C;
7+
create table t2 (
8+
kp1 int,
9+
kp2 int,
10+
col char(100),
11+
key(kp1, kp2)
12+
);
13+
insert into t2 select a, a, a from t1;
14+
select engine from information_schema.tables
15+
where table_schema=database() and table_name='t2';
16+
engine
17+
InnoDB
18+
explain
19+
select * from t2 where kp1 between 10 and 20 and kp2 +1 >100;
20+
id select_type table type possible_keys key key_len ref rows Extra
21+
1 SIMPLE t2 range kp1 kp1 5 NULL 11 Using index condition
22+
set debug_sync='handler_index_cond_check SIGNAL at_icp_check WAIT_FOR go';
23+
select * from t2 where kp1 between 10 and 20 and kp2 +1 >100;
24+
connect con1, localhost, root,,;
25+
connection con1;
26+
set debug_sync='now WAIT_FOR at_icp_check';
27+
kill query $target_id;
28+
set debug_sync='now SIGNAL go';
29+
connection default;
30+
ERROR 70100: Query execution was interrupted
31+
set debug_sync='RESET';
32+
disconnect con1;
33+
drop table t0,t1,t2;
34+
set default_storage_engine=default;

mysql-test/main/innodb_icp_debug.test

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
--source include/have_innodb.inc
2+
3+
set default_storage_engine=innodb;
4+
--source include/icp_debug_kill.inc
5+
set default_storage_engine=default;
6+
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
drop table if exists t0,t1,t2;
2+
create table t0(a int primary key);
3+
insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
4+
create table t1(a int primary key);
5+
insert into t1 select A.a + B.a* 10 + C.a * 100 from t0 A, t0 B, t0 C;
6+
create table t2 (
7+
kp1 int,
8+
kp2 int,
9+
col char(100),
10+
key(kp1, kp2)
11+
);
12+
insert into t2 select a, a, a from t1;
13+
select engine from information_schema.tables
14+
where table_schema=database() and table_name='t2';
15+
engine
16+
MyISAM
17+
explain
18+
select * from t2 where kp1 between 10 and 20 and kp2 +1 >100;
19+
id select_type table type possible_keys key key_len ref rows Extra
20+
1 SIMPLE t2 range kp1 kp1 5 NULL 11 Using index condition
21+
set debug_sync='handler_index_cond_check SIGNAL at_icp_check WAIT_FOR go';
22+
select * from t2 where kp1 between 10 and 20 and kp2 +1 >100;
23+
connect con1, localhost, root,,;
24+
connection con1;
25+
set debug_sync='now WAIT_FOR at_icp_check';
26+
kill query $target_id;
27+
set debug_sync='now SIGNAL go';
28+
connection default;
29+
ERROR 70100: Query execution was interrupted
30+
set debug_sync='RESET';
31+
disconnect con1;
32+
drop table t0,t1,t2;

mysql-test/main/myisam_icp_debug.test

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
--source include/icp_debug_kill.inc

mysql-test/main/rowid_filter_innodb_debug.result

Lines changed: 59 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,59 @@
1+
set default_storage_engine=innodb;
2+
#
3+
# MDEV-22761 KILL QUERY during rowid_filter, crashes
4+
#
5+
create table t0(a int);
6+
insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
7+
create table t1(a int);
8+
insert into t1 select A.a + B.a* 10 + C.a * 100 from t0 A, t0 B, t0 C;
9+
create table t2(a int);
10+
insert into t2 select A.a + B.a* 10 from t0 A, t0 B;
11+
CREATE TABLE t3 (
12+
key1 int ,
13+
key2 int,
14+
filler varchar(255),
15+
KEY (key1),
16+
KEY (key2)
17+
);
18+
select engine from information_schema.tables
19+
where table_schema=database() and table_name='t3';
20+
engine
21+
InnoDB
22+
insert into t3
23+
select
24+
A.a,
25+
A.a,
26+
'filler-data-filler-data'
27+
from
28+
t0 A, t1 B;
29+
analyze table t2,t3;
30+
Table Op Msg_type Msg_text
31+
test.t2 analyze status Engine-independent statistics collected
32+
test.t2 analyze status OK
33+
test.t3 analyze status Engine-independent statistics collected
34+
test.t3 analyze status OK
35+
explain
36+
select * from t2, t3
37+
where
38+
t3.key1=t2.a and t3.key2 in (2,3);
39+
id select_type table type possible_keys key key_len ref rows Extra
40+
1 SIMPLE t2 ALL NULL NULL NULL NULL 100 Using where
41+
1 SIMPLE t3 ref|filter key1,key2 key1|key2 5|5 test.t2.a 1000 (20%) Using where; Using rowid filter
42+
set debug_sync='handler_rowid_filter_check SIGNAL at_rowid_filter_check WAIT_FOR go';
43+
select * from t2, t3
44+
where
45+
t3.key1=t2.a and t3.key2 in (2,3);
46+
connect con1, localhost, root,,;
47+
connection con1;
48+
set debug_sync='now WAIT_FOR at_rowid_filter_check';
49+
kill query $target_id;
50+
set debug_sync='now SIGNAL go';
51+
connection default;
52+
disconnect con1;
53+
ERROR 70100: Query execution was interrupted
54+
set debug_sync='RESET';
55+
drop table t0,t1,t2,t3;
56+
set default_storage_engine=default;
157
set @save_optimizer_switch= @@optimizer_switch;
258
set @save_use_stat_tables= @@use_stat_tables;
359
set @save_optimizer_use_condition_selectivity= @@optimizer_use_condition_selectivity;
@@ -6,18 +62,19 @@ set optimizer_use_condition_selectivity=2;
662
set optimizer_switch='rowid_filter=on';
763
#
864
# MDEV-22761 KILL QUERY during rowid_filter, crashes
65+
# (The smaller testcase)
966
#
1067
CREATE TABLE t1 (a INT, b INT, INDEX(a), INDEX(b)) ENGINE=InnoDB;
1168
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';
69+
set debug_sync='handler_rowid_filter_check SIGNAL killme WAIT_FOR go';
1370
SELECT * FROM t1 WHERE a > 0 AND b=0;
1471
connect con1, localhost, root,,;
1572
connection con1;
1673
set debug_sync='now WAIT_FOR killme';
1774
kill query @id;
1875
set debug_sync='now SIGNAL go';
1976
connection default;
20-
a b
77+
ERROR 70100: Query execution was interrupted
2178
set debug_sync='RESET';
2279
disconnect con1;
2380
drop table t1;

mysql-test/main/rowid_filter_innodb_debug.test

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
--source include/have_debug.inc
2-
--source include/have_debug_sync.inc
31
--source include/have_innodb.inc
2+
3+
set default_storage_engine=innodb;
4+
--source include/rowid_filter_debug_kill.inc
5+
set default_storage_engine=default;
6+
47
--source include/default_optimizer_switch.inc
58
--source include/count_sessions.inc
69

@@ -15,14 +18,15 @@ set optimizer_switch='rowid_filter=on';
1518

1619
--echo #
1720
--echo # MDEV-22761 KILL QUERY during rowid_filter, crashes
21+
--echo # (The smaller testcase)
1822
--echo #
1923

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

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

25-
set debug_sync='row_search_pre_rowid_filter_check SIGNAL killme WAIT_FOR go';
29+
set debug_sync='handler_rowid_filter_check SIGNAL killme WAIT_FOR go';
2630
send SELECT * FROM t1 WHERE a > 0 AND b=0;
2731

2832
connect (con1, localhost, root,,);
@@ -33,6 +37,7 @@ kill query @id;
3337
set debug_sync='now SIGNAL go';
3438

3539
connection default;
40+
--error ER_QUERY_INTERRUPTED
3641
reap;
3742
set debug_sync='RESET';
3843

0 commit comments

Comments
 (0)