From 252d82bf3345770a0b70d21c6adfd4392ba30f8e Mon Sep 17 00:00:00 2001 From: qingxinsun Date: Mon, 17 Oct 2022 11:56:59 +0800 Subject: [PATCH] test case for opt thread --- ...se_cachelock_before_sync_trx_commit.result | 19 +++++++++ ...ease_cachelock_before_sync_trx_commit.test | 41 +++++++++++++++++++ storage/innobase/fts/fts0fts.cc | 3 ++ 3 files changed, 63 insertions(+) create mode 100644 mysql-test/suite/innodb_fts/r/opt_release_cachelock_before_sync_trx_commit.result create mode 100644 mysql-test/suite/innodb_fts/t/opt_release_cachelock_before_sync_trx_commit.test diff --git a/mysql-test/suite/innodb_fts/r/opt_release_cachelock_before_sync_trx_commit.result b/mysql-test/suite/innodb_fts/r/opt_release_cachelock_before_sync_trx_commit.result new file mode 100644 index 00000000..9463cff5 --- /dev/null +++ b/mysql-test/suite/innodb_fts/r/opt_release_cachelock_before_sync_trx_commit.result @@ -0,0 +1,19 @@ +CREATE TABLE t1 ( +id1 INT , +a1 VARCHAR(200) , +b1 TEXT , +FULLTEXT KEY (a1,b1), PRIMARY KEY (a1, id1) +) CHARACTER SET = utf8 , ENGINE = InnoDB; +Warnings: +Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. +set global debug="+d,fts_instrument_sync_request"; +INSERT INTO t1 (id1,a1,b1) VALUES +(1,'MySQL Tutorial','DBMS stands for DataBase VÐƷWİ...'); +SELECT * FROM t1 WHERE MATCH (a1,b1) AGAINST ('tutorial') ORDER BY id1; +id1 a1 b1 +1 MySQL Tutorial DBMS stands for DataBase VÐƷWİ... +SELECT * FROM t1 WHERE MATCH (a1,b1) AGAINST ('tutorial') ORDER BY id1; +id1 a1 b1 +1 MySQL Tutorial DBMS stands for DataBase VÐƷWİ... +drop table t1; +set global debug="-d,fts_instrument_sync_request"; diff --git a/mysql-test/suite/innodb_fts/t/opt_release_cachelock_before_sync_trx_commit.test b/mysql-test/suite/innodb_fts/t/opt_release_cachelock_before_sync_trx_commit.test new file mode 100644 index 00000000..a782093c --- /dev/null +++ b/mysql-test/suite/innodb_fts/t/opt_release_cachelock_before_sync_trx_commit.test @@ -0,0 +1,41 @@ +## +# FTS opt thread clean fts cache and release cache lock before the written +# data is committed(flush cache data trx). +# Query using fts index will not read the data cached during this time. +## + +--source include/have_debug_sync.inc +--source include/have_debug.inc + +CREATE TABLE t1 ( + id1 INT , + a1 VARCHAR(200) , + b1 TEXT , + FULLTEXT KEY (a1,b1), PRIMARY KEY (a1, id1) + ) CHARACTER SET = utf8 , ENGINE = InnoDB; + + +# let the fts opt thread sleep after fts cache lock release , before trx(flush cache data trx) commit +# opt thread sleep 5 secs. +set global debug="+d,fts_instrument_sync_request"; + +# Insert rows +INSERT INTO t1 (id1,a1,b1) VALUES + (1,'MySQL Tutorial','DBMS stands for DataBase VÐƷWİ...'); + +#let fts opt thread sleep after release fts cache lock, before fts_sql_commit, unconsistent point +--sleep 4 + +# read uncosistent, if release lock before trx commit +SELECT * FROM t1 WHERE MATCH (a1,b1) AGAINST ('tutorial') ORDER BY id1; + +# wait for fts opt thread to go on, commit 'flush fts cache' trx. +--sleep 10 + +# After the sleep, data is committed. read consistent +SELECT * FROM t1 WHERE MATCH (a1,b1) AGAINST ('tutorial') ORDER BY id1; + +drop table t1; + +set global debug="-d,fts_instrument_sync_request"; + diff --git a/storage/innobase/fts/fts0fts.cc b/storage/innobase/fts/fts0fts.cc index 696042f0..6ec10be9 100644 --- a/storage/innobase/fts/fts0fts.cc +++ b/storage/innobase/fts/fts0fts.cc @@ -4276,6 +4276,9 @@ static MY_ATTRIBUTE((warn_unused_result)) dberr_t fts_cache_init(cache); rw_lock_x_unlock(&cache->lock); + /* If query come in at this point, fts cache is cleaned, but fts trx is not committed, unconsistent point */ + DBUG_EXECUTE_IF("fts_instrument_sync_request", os_thread_sleep(10 * 1000 * 1000);); + if (error == DB_SUCCESS) { fts_sql_commit(trx); -- 2.19.1