flush_read_lock_kill.test 2.05 KB
Newer Older
1 2 3 4 5 6 7 8 9
# Let's see if FLUSH TABLES WITH READ LOCK can be killed when waiting
# for running commits to finish (in the past it could not)
# This will not be a meaningful test on non-debug servers so will be
# skipped.
# If running mysql-test-run --debug, the --debug added by
# mysql-test-run to the mysqld command line will override the one of
# -master.opt. But this test is designed to still pass then (though it
# won't test anything interesting).

10
# This also won't work with the embedded server test
11
--source include/not_embedded.inc
12

13 14 15 16 17 18 19 20 21
--source include/have_debug.inc

# Save the initial number of concurrent sessions
--source include/count_sessions.inc

# Disable concurrent inserts to avoid test failures when reading the
# connection id which was inserted into a table by another thread.
SET @old_concurrent_insert= @@global.concurrent_insert;
SET @@global.concurrent_insert= 0;
22 23 24 25 26 27

connect (con1,localhost,root,,);
connect (con2,localhost,root,,);
connection con1;

--disable_warnings
28
DROP TABLE IF EXISTS t1;
29
--enable_warnings
30 31
CREATE TABLE t1 (kill_id INT);
INSERT INTO t1 VALUES(connection_id());
32 33 34 35 36 37 38

# Thanks to the parameter we passed to --debug, this FLUSH will
# block on a debug build running with our --debug=make_global... It
# will block until killed. In other cases (non-debug build or other
# --debug) it will succeed immediately

connection con1;
39
send FLUSH TABLES WITH READ LOCK;
40 41 42

# kill con1
connection con2;
43
SELECT ((@id := kill_id) - kill_id) FROM t1;
44

45
--sleep 2 # leave time for FLUSH to block
46
KILL CONNECTION @id;
47 48 49 50 51 52

connection con1;
# On debug builds it will be error 1053 (killed); on non-debug, or
# debug build running without our --debug=make_global..., will be
# error 0 (no error). The only important thing to test is that on
# debug builds with our --debug=make_global... we don't hang forever.
53
--error 0,1053,2013
54 55 56
reap;

connection con2;
57 58 59 60 61 62 63 64 65 66
DROP TABLE t1;
connection default;
disconnect con2;

# Restore global concurrent_insert value
SET @@global.concurrent_insert= @old_concurrent_insert;

# Wait till all disconnects are completed
--source include/wait_until_count_sessions.inc