2004-12-02 23:02:38 +01:00
|
|
|
# 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.
|
|
|
|
|
2005-04-04 21:43:58 +02:00
|
|
|
# This also won't work with the embedded server test
|
2009-03-03 21:34:18 +01:00
|
|
|
--source include/not_embedded.inc
|
2005-04-04 21:43:58 +02:00
|
|
|
|
2009-03-03 21:34:18 +01:00
|
|
|
--source include/have_debug.inc
|
|
|
|
|
2010-11-11 18:11:05 +01:00
|
|
|
# This test needs transactional engine as otherwise COMMIT
|
|
|
|
# won't block FLUSH TABLES WITH GLOBAL READ LOCK.
|
|
|
|
--source include/have_innodb.inc
|
|
|
|
|
2009-03-03 21:34:18 +01:00
|
|
|
# Save the initial number of concurrent sessions
|
|
|
|
--source include/count_sessions.inc
|
2004-12-02 23:02:38 +01:00
|
|
|
|
|
|
|
connect (con1,localhost,root,,);
|
|
|
|
connect (con2,localhost,root,,);
|
|
|
|
connection con1;
|
|
|
|
|
|
|
|
--disable_warnings
|
2009-03-03 21:34:18 +01:00
|
|
|
DROP TABLE IF EXISTS t1;
|
2004-12-02 23:02:38 +01:00
|
|
|
--enable_warnings
|
2010-11-11 18:11:05 +01:00
|
|
|
SET DEBUG_SYNC= 'RESET';
|
|
|
|
CREATE TABLE t1 (kill_id INT) engine = InnoDB;
|
|
|
|
INSERT INTO t1 VALUES(connection_id());
|
|
|
|
|
|
|
|
--echo # Switching to connection 'default'.
|
|
|
|
connection default;
|
|
|
|
--echo # Start transaction.
|
|
|
|
BEGIN;
|
2009-03-03 21:34:18 +01:00
|
|
|
INSERT INTO t1 VALUES(connection_id());
|
2010-11-11 18:11:05 +01:00
|
|
|
--echo # Ensure that COMMIT will pause once it acquires protection
|
|
|
|
--echo # against its global read lock.
|
|
|
|
SET DEBUG_SYNC='ha_commit_trans_after_acquire_commit_lock SIGNAL acquired WAIT_FOR go';
|
2004-12-02 23:02:38 +01:00
|
|
|
|
2010-11-11 18:11:05 +01:00
|
|
|
--echo # Sending:
|
|
|
|
--send COMMIT
|
2004-12-02 23:02:38 +01:00
|
|
|
|
2010-11-11 18:11:05 +01:00
|
|
|
--echo # Switching to 'con1'.
|
2004-12-02 23:02:38 +01:00
|
|
|
connection con1;
|
2010-11-11 18:11:05 +01:00
|
|
|
--echo # Wait till COMMIT acquires protection against global read
|
|
|
|
--echo # lock and pauses.
|
|
|
|
SET DEBUG_SYNC='now WAIT_FOR acquired';
|
|
|
|
--echo # Sending:
|
2009-03-03 21:34:18 +01:00
|
|
|
send FLUSH TABLES WITH READ LOCK;
|
2004-12-02 23:02:38 +01:00
|
|
|
|
2010-11-11 18:11:05 +01:00
|
|
|
--echo # Switching to 'con2'.
|
2004-12-02 23:02:38 +01:00
|
|
|
connection con2;
|
2010-11-11 18:11:05 +01:00
|
|
|
SELECT ((@id := kill_id) - kill_id) FROM t1 LIMIT 1;
|
2004-12-02 23:02:38 +01:00
|
|
|
|
2010-11-11 18:11:05 +01:00
|
|
|
--echo # Wait till FLUSH TABLES WITH READ LOCK blocks due
|
|
|
|
--echo # to active COMMIT
|
2008-02-27 22:08:29 +01:00
|
|
|
let $wait_condition=
|
|
|
|
select count(*) = 1 from information_schema.processlist
|
2010-11-11 18:11:05 +01:00
|
|
|
where state = "Waiting for commit lock"
|
2008-02-27 22:08:29 +01:00
|
|
|
and info = "flush tables with read lock";
|
|
|
|
--source include/wait_condition.inc
|
|
|
|
|
2010-11-11 18:11:05 +01:00
|
|
|
--echo # Kill connection 'con1'.
|
2009-03-03 21:34:18 +01:00
|
|
|
KILL CONNECTION @id;
|
2004-12-02 23:02:38 +01:00
|
|
|
|
2010-11-11 18:11:05 +01:00
|
|
|
--echo # Switching to 'con1'.
|
2004-12-02 23:02:38 +01:00
|
|
|
connection con1;
|
2010-11-11 18:11:05 +01:00
|
|
|
--echo # Try to reap FLUSH TABLES WITH READ LOCK,
|
|
|
|
--echo # it fail due to killed statement and connection.
|
|
|
|
--error 1317,2013
|
2004-12-02 23:02:38 +01:00
|
|
|
reap;
|
|
|
|
|
2010-11-11 18:11:05 +01:00
|
|
|
--echo # Switching to 'con2'.
|
2004-12-02 23:02:38 +01:00
|
|
|
connection con2;
|
2010-11-11 18:11:05 +01:00
|
|
|
--echo # Resume COMMIT.
|
|
|
|
SET DEBUG_SYNC='now SIGNAL go';
|
2009-03-06 15:56:17 +01:00
|
|
|
|
2010-11-11 18:11:05 +01:00
|
|
|
--echo # Switching to 'default'.
|
2008-03-13 18:54:29 +01:00
|
|
|
connection default;
|
2010-11-11 18:11:05 +01:00
|
|
|
--echo # Reaping COMMIT.
|
|
|
|
--reap
|
2009-03-03 21:34:18 +01:00
|
|
|
disconnect con2;
|
2010-11-11 18:11:05 +01:00
|
|
|
DROP TABLE t1;
|
|
|
|
SET DEBUG_SYNC= 'RESET';
|
2009-03-03 21:34:18 +01:00
|
|
|
|
|
|
|
# Wait till all disconnects are completed
|
|
|
|
--source include/wait_until_count_sessions.inc
|
|
|
|
|