diff options
author | Krunal Bauskar krunal.bauskar@oracle.com <> | 2012-10-15 09:24:33 +0530 |
---|---|---|
committer | Krunal Bauskar krunal.bauskar@oracle.com <> | 2012-10-15 09:24:33 +0530 |
commit | c8cebffdbdd0ba2dadff59d05d8f462a95eb46ce (patch) | |
tree | ea32153f7c39382e3572783adcd466a770574d62 | |
parent | c8f6ab29168e4f9a79b1141e36348a21e7e9bc08 (diff) | |
download | mariadb-git-c8cebffdbdd0ba2dadff59d05d8f462a95eb46ce.tar.gz |
bug#14704286
SECONDARY INDEX UPDATES MAKE CONSISTENT READS DO O(N^2) UNDO PAGE
LOOKUPS (honoring kill query while accessing sec_index)
If secondary index is being used for select query evaluation and this
query is operating with consistent read snapshot it might take good time for
secondary index to return back control to mysql as MVCC would kick in.
If user issues "kill query <id>" while query is actively accessing
secondary index it will not be honored as there is no hook to check
for this condition. Added hook for this check.
-----
Parallely secondary index taking too long to evaluate for consistent
read snapshot case is being examined for performance improvement. WL#6540.
-rw-r--r-- | mysql-test/suite/innodb/r/innodb_bug14704286.result | 43 | ||||
-rw-r--r-- | mysql-test/suite/innodb/t/innodb_bug14704286.test | 89 | ||||
-rw-r--r-- | storage/innobase/row/row0sel.c | 6 | ||||
-rw-r--r-- | storage/innodb_plugin/row/row0sel.c | 5 |
4 files changed, 142 insertions, 1 deletions
diff --git a/mysql-test/suite/innodb/r/innodb_bug14704286.result b/mysql-test/suite/innodb/r/innodb_bug14704286.result new file mode 100644 index 00000000000..9703955cfa7 --- /dev/null +++ b/mysql-test/suite/innodb/r/innodb_bug14704286.result @@ -0,0 +1,43 @@ +use test; +drop table if exists t1; +Warnings: +Note 1051 Unknown table 't1' +create table t1 (id int primary key, value int, value2 int, +value3 int, index(value,value2)) engine=innodb; +insert into t1 values +(10,10,10,10),(11,11,11,11),(12,12,12,12),(13,13,13,13),(14,14,14,14), +(15,15,15,15),(16,16,16,16),(17,17,17,17),(18,18,18,18),(19,19,19,19), +(20,20,20,20); +use test; +start transaction with consistent snapshot; +use test; +CREATE PROCEDURE update_t1() +BEGIN +DECLARE i INT DEFAULT 1; +while (i <= 5000) DO +update test.t1 set value2=value2+1, value3=value3+1 where id=12; +SET i = i + 1; +END WHILE; +END| +CALL update_t1(); +select * from t1; +id value value2 value3 +10 10 10 10 +11 11 11 11 +12 12 5012 5012 +13 13 13 13 +14 14 14 14 +15 15 15 15 +16 16 16 16 +17 17 17 17 +18 18 18 18 +19 19 19 19 +20 20 20 20 +select * from t1 force index(value) where value=12; +kill query @id; +ERROR 70100: Query execution was interrupted +select * from t1 where value = 12; +id value value2 value3 +12 12 12 12 +drop procedure if exists update_t1; +drop table if exists t1; diff --git a/mysql-test/suite/innodb/t/innodb_bug14704286.test b/mysql-test/suite/innodb/t/innodb_bug14704286.test new file mode 100644 index 00000000000..bdc2ab94b01 --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb_bug14704286.test @@ -0,0 +1,89 @@ +--source include/have_innodb.inc + +# +# create test-bed to run test +# +use test; + +drop table if exists t1; +create table t1 (id int primary key, value int, value2 int, +value3 int, index(value,value2)) engine=innodb; + +insert into t1 values +(10,10,10,10),(11,11,11,11),(12,12,12,12),(13,13,13,13),(14,14,14,14), +(15,15,15,15),(16,16,16,16),(17,17,17,17),(18,18,18,18),(19,19,19,19), +(20,20,20,20); +let $ID= `SELECT @id := CONNECTION_ID()`; + +# +# we need multiple connections as we need to keep one connection +# active with trx requesting consistent read. +# +connect (conn1, localhost, root,,); +connect (conn2, localhost, root,,); +connect (conn3, localhost, root,,); + +# +# start trx with consistent read +# +connection conn1; +use test; + +start transaction with consistent snapshot; + +# +# update table such that secondary index is updated. +# +connection conn2; +use test; +delimiter |; +CREATE PROCEDURE update_t1() +BEGIN + DECLARE i INT DEFAULT 1; + while (i <= 5000) DO + update test.t1 set value2=value2+1, value3=value3+1 where id=12; + SET i = i + 1; + END WHILE; +END| + +delimiter ;| + +CALL update_t1(); +select * from t1; + +# +# Now try to fire select query from connection-1 enforcing +# use of secondary index. +# +connection conn1; +let $ID= `SELECT @id := CONNECTION_ID()`; +#--error ER_QUERY_INTERRUPTED +--send +select * from t1 force index(value) where value=12; + +# +# select is going to take good time so let's kill query. +# +connection conn3; +let $ignore= `SELECT @id := $ID`; +kill query @id; + +# +# reap the value of connection-1 +# +connection conn1; +--error ER_QUERY_INTERRUPTED +reap; +select * from t1 where value = 12; + +# +# clean test-bed. +# +connection default; +disconnect conn1; +disconnect conn2; +disconnect conn3; +drop procedure if exists update_t1; +drop table if exists t1; + + diff --git a/storage/innobase/row/row0sel.c b/storage/innobase/row/row0sel.c index 915cc8339d4..c600fa62151 100644 --- a/storage/innobase/row/row0sel.c +++ b/storage/innobase/row/row0sel.c @@ -3758,9 +3758,13 @@ wait_table_again: } rec_loop: + if (trx_is_interrupted(trx)) { + err = DB_INTERRUPTED; + goto normal_return; + } + /*-------------------------------------------------------------*/ /* PHASE 4: Look for matching records in a loop */ - rec = btr_pcur_get_rec(pcur); ut_ad(!!page_rec_is_comp(rec) == comp); #ifdef UNIV_SEARCH_DEBUG diff --git a/storage/innodb_plugin/row/row0sel.c b/storage/innodb_plugin/row/row0sel.c index 54172e71a47..c70a477db1d 100644 --- a/storage/innodb_plugin/row/row0sel.c +++ b/storage/innodb_plugin/row/row0sel.c @@ -3908,6 +3908,11 @@ wait_table_again: } rec_loop: + if (trx_is_interrupted(trx)) { + err = DB_INTERRUPTED; + goto normal_return; + } + /*-------------------------------------------------------------*/ /* PHASE 4: Look for matching records in a loop */ |