mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 20:12:31 +01:00
e63b5546c5
It includes speed optimizations for HANDLER READ by caching as much as possible in HANDLER OPEN Other things: - Added mysqld option --disable-thr-alarm to be able to benchmark things without thr_alarm - Changed 'Locked' state to 'System lock' and 'Table lock' (these where used in the code but never shown to end user) - Better error message if mysql_install_db.sh fails - Moved handler function prototypes to sql_handler.h - Remove not anymore used 'thd->locked' member include/thr_alarm.h: Added my_disable_thr_alarm include/thr_lock.h: Add new member to THR_LOCK_DATA to remember original lock type state. This is needed as thr_unlock() resets type to TL_UNLOCK. mysql-test/include/check_no_concurrent_insert.inc: Locked -> Table lock mysql-test/include/handler.inc: Locked -> Table lock mysql-test/r/handler_innodb.result: Updated results for new tests mysql-test/r/handler_myisam.result: Updated results for new tests mysql-test/r/sp-threads.result: Locked -> Table lock mysql-test/suite/binlog/t/binlog_stm_row.test: Locked -> Table lock mysql-test/suite/funcs_1/datadict/processlist_val.inc: Locked -> Table lock mysql-test/suite/pbxt/t/lock_multi.test: Locked -> Table lock mysql-test/suite/sys_vars/r/concurrent_insert_func.result: Locked -> Table lock mysql-test/suite/sys_vars/t/concurrent_insert_func.test: Locked -> Table lock mysql-test/suite/sys_vars/t/delayed_insert_limit_func.test: Locked -> Table lock mysql-test/suite/sys_vars/t/query_cache_wlock_invalidate_func.test: Locked -> Table lock mysql-test/suite/sys_vars/t/sql_low_priority_updates_func.test: Locked -> Table lock mysql-test/t/insert_notembedded.test: Locked -> Table lock mysql-test/t/lock_multi.test: Locked -> Table lock mysql-test/t/merge-big.test: Locked -> Table lock mysql-test/t/multi_update.test: Locked -> Table lock mysql-test/t/query_cache_28249.test: Locked -> Table lock mysql-test/t/sp_notembedded.test: Locked -> Table lock mysql-test/t/sp_sync.test: Locked -> Table lock mysql-test/t/status.test: Locked -> Table lock mysql-test/t/trigger_notembedded.test: Locked -> Table lock mysys/thr_alarm.c: Added option to disable thr_alarm mysys/thr_lock.c: Detect loops scripts/mysql_install_db.sh: Give better error message if something goes wrong sql/Makefile.am: Added sql_handler.h sql/lock.cc: Split functions to allow one to cache value if store_lock() (for HANDLER functions). - Split mysql_lock_tables() into two functions, where first one allocates MYSQL_LOCK and other other one uses it. - Made get_lock_data() an external function. - Added argument to mysql_unlock_tables() to not free sql_lock. - Added argument to reset_lock_data() to reset lock structure to initial state (as after get_lock_data()) sql/mysql_priv.h: Moved handler function prototypes to sql_handler.h Added new lock functions. sql/mysqld.cc: Added --thread-alarm startup option sql/net_serv.cc: Don't call vio_blocking() if not needed sql/sql_base.cc: include sql_handler.h sql/sql_class.cc: include sql_handler.h Remove not anymore used 'thd->locked' member sql/sql_class.h: Remove not anymore used 'thd->locked' member sql/sql_db.cc: include sql_handler.h sql/sql_delete.cc: include sql_handler.h sql/sql_handler.cc: Rewrote all code to use SQL_HANDLER instead of TABLE_LIST (original interface) Rewrote mysql_ha_open() to cache all things from TABLE_LIST and items for field list, where etc. In mysql_ha_open() also cache MYSQL_LOCK structure from get_lock_data(). Split functions into smaller sub functions (needed to be able to implement mysql_ha_read_prepare()) Added mysql_ha_read_prepare() to allow one to prepare HANDLER READ. sql/sql_handler.h: Interface to sql_handler.cc sql/sql_parse.cc: include sql_handler.h sql/sql_prepare.cc: Added mysql_test_handler_read(), prepare for HANDLER READ sql/sql_rename.cc: include sql_handler.h sql/sql_show.cc: Removed usage of thd->locked sql/sql_table.cc: include sql_handler.h sql/sql_trigger.cc: include sql_handler.h
124 lines
4.1 KiB
Text
124 lines
4.1 KiB
Text
### t/query_cache_28249.test ###
|
|
#
|
|
# Test for
|
|
# Bug#28249 Query Cache returns wrong result with concurrent insert / certain lock
|
|
#
|
|
# Last modification:
|
|
# 2008-11-27 mleich - Move this test out of query_cache.test
|
|
# - Fix Bug#40179 Test main.query_cache failing randomly on Pushbuild,
|
|
# test weakness
|
|
# - Minor improvements (comments,formatting etc.)
|
|
#
|
|
|
|
--source include/have_query_cache.inc
|
|
--source include/not_embedded.inc
|
|
|
|
SET @query_cache_type= @@global.query_cache_type;
|
|
SET @query_cache_limit= @@global.query_cache_limit;
|
|
SET @query_cache_min_res_unit= @@global.query_cache_min_res_unit;
|
|
SET @query_cache_size= @@global.query_cache_size;
|
|
|
|
--echo # Bug#28249 Query Cache returns wrong result with concurrent insert/ certain lock
|
|
--echo # Establish connections user1,user2,user3 (user=root)
|
|
connect (user1,localhost,root,,test,,);
|
|
connect (user2,localhost,root,,test,,);
|
|
connect (user3,localhost,root,,test,,);
|
|
|
|
--echo # Switch to connection user1
|
|
connection user1;
|
|
|
|
SET GLOBAL query_cache_type=1;
|
|
SET GLOBAL query_cache_limit=10000;
|
|
SET GLOBAL query_cache_min_res_unit=0;
|
|
SET GLOBAL query_cache_size= 100000;
|
|
|
|
FLUSH TABLES;
|
|
--disable_warnings
|
|
DROP TABLE IF EXISTS t1, t2;
|
|
--enable_warnings
|
|
CREATE TABLE t1 (a INT);
|
|
CREATE TABLE t2 (a INT);
|
|
INSERT INTO t1 VALUES (1),(2),(3);
|
|
|
|
--echo # Switch to connection user2
|
|
connection user2;
|
|
LOCK TABLE t2 WRITE;
|
|
|
|
--echo # Switch to connection user1
|
|
connection user1;
|
|
--echo # "send" the next select, "reap" the result later.
|
|
--echo # The select will be blocked by the write lock on the t1.
|
|
let $select_for_qc =
|
|
SELECT *, (SELECT COUNT(*) FROM t2) FROM t1;
|
|
send;
|
|
eval $select_for_qc;
|
|
|
|
--echo # Switch to connection user3
|
|
connection user3;
|
|
# Typical information_schema.processlist content after sufficient sleep time
|
|
# ID USER COMMAND TIME STATE INFO
|
|
# ....
|
|
# 2 root Query 5 Locked SELECT *, (SELECT COUNT(*) FROM t2) FROM t1
|
|
# ....
|
|
# XXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
|
|
# The values marked with 'X' must be reached.
|
|
--echo # Poll till the select of connection user1 is blocked by the write lock on t1.
|
|
let $wait_condition= SELECT COUNT(*) = 1 FROM information_schema.processlist
|
|
WHERE state = "Table Lock"
|
|
AND info = '$select_for_qc';
|
|
--source include/wait_condition.inc
|
|
eval
|
|
SELECT user,command,state,info FROM information_schema.processlist
|
|
WHERE state = "Table Lock"
|
|
AND info = '$select_for_qc';
|
|
INSERT INTO t1 VALUES (4);
|
|
|
|
--echo # Switch to connection user2
|
|
connection user2;
|
|
UNLOCK TABLES;
|
|
|
|
--echo # Switch to connection user1
|
|
connection user1;
|
|
#
|
|
# Since the lock ordering rule in thr_multi_lock depends on
|
|
# pointer values, from execution to execution we might have
|
|
# different lock order, and therefore, sometimes lock t1 and block
|
|
# on t2, and sometimes block on t2 right away. In the second case,
|
|
# the following insert succeeds, and only then this select can
|
|
# proceed, and we actually test nothing, as the very first select
|
|
# returns 4 rows right away.
|
|
# It's fine to have a test case that covers the problematic area
|
|
# at least once in a while.
|
|
--echo # Collecting ("reap") the result from the previously blocked select.
|
|
--echo # The printing of the result (varies between 3 and 4 rows) set has to be suppressed.
|
|
--disable_result_log
|
|
--reap
|
|
--enable_result_log
|
|
|
|
--echo # Switch to connection user3
|
|
connection user3;
|
|
--echo # The next select enforces that effects of "concurrent_inserts" like the
|
|
--echo # record with a = 4 is missing in result sets can no more happen.
|
|
SELECT 1 FROM t1 WHERE a = 4;
|
|
|
|
--echo # Switch to connection user1
|
|
connection user1;
|
|
--echo # The next result set must contain 4 rows.
|
|
# If not, we have a regression of Bug#28249
|
|
eval $select_for_qc;
|
|
RESET QUERY CACHE;
|
|
eval $select_for_qc;
|
|
|
|
DROP TABLE t1,t2;
|
|
|
|
--echo # Switch to connection default + close connections user1,user2,user3
|
|
connection default;
|
|
disconnect user1;
|
|
disconnect user2;
|
|
disconnect user3;
|
|
|
|
SET GLOBAL query_cache_type= @query_cache_type;
|
|
SET GLOBAL query_cache_limit= @query_cache_limit;
|
|
SET GLOBAL query_cache_min_res_unit= @query_cache_min_res_unit;
|
|
SET GLOBAL query_cache_size= @query_cache_size;
|
|
|