Commit 4102d525 authored by Philip Stoev's avatar Philip Stoev Committed by Nirbhay Choubey

Refs codership/mysql-wsrep#113 - tests around FLUSH TABLE, FLUSH TABLES, LOCK TABLE

parent 2106fed8
SET SESSION wsrep_sync_wait = 0;
CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB;
FLUSH TABLE t1 WITH READ LOCK;
INSERT INTO t1 VALUES (1);
INSERT INTO t1 VALUES (2);
SET SESSION wsrep_sync_wait = 0;
SELECT COUNT(*) = 0 FROM t1;
COUNT(*) = 0
1
UNLOCK TABLES;
SET SESSION wsrep_sync_wait = 7;
SELECT COUNT(*) = 2 FROM t1;
COUNT(*) = 2
1
DROP TABLE t1;
SET SESSION wsrep_sync_wait = 0;
SET SESSION lock_wait_timeout = 60;
SET SESSION innodb_lock_wait_timeout=60;
SET SESSION wait_timeout=60;
CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB;
FLUSH TABLE t1 WITH READ LOCK;
ALTER TABLE t1 ADD COLUMN f2 INTEGER;
SELECT 1 FROM DUAL;
1
1
SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND STATE = 'Waiting for table metadata lock';
COUNT(*) = 1
1
UNLOCK TABLES;
SET SESSION wsrep_sync_wait = 7;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`f1` int(11) NOT NULL,
`f2` int(11) DEFAULT NULL,
PRIMARY KEY (`f1`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND STATE = 'Waiting for table metadata lock';
COUNT(*) = 0
1
DROP TABLE t1;
CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB;
SET AUTOCOMMIT=OFF;
FLUSH TABLES t1 FOR EXPORT;
INSERT INTO t1 VALUES (2);
SET SESSION wsrep_sync_wait = 0;
UNLOCK TABLES;
COMMIT;
SELECT COUNT(*) = 1 FROM t1;
COUNT(*) = 1
1
wsrep_local_aborts_increment
1
DROP TABLE t1;
CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB;
SET AUTOCOMMIT=OFF;
LOCK TABLE t1 WRITE;
INSERT INTO t1 VALUES (1);;
INSERT INTO t1 VALUES (2);
UNLOCK TABLES;
COMMIT;
SELECT COUNT(*) = 1 FROM t1;
COUNT(*) = 1
1
wsrep_local_aborts_increment
1
DROP TABLE t1;
#
# Test that applying plays well with FLUSH TABLE table_name WITH READ LOCK. The applier
# thread should block until UNLOCK TABLEs.
#
--source include/galera_cluster.inc
--source include/have_innodb.inc
--connection node_1
SET SESSION wsrep_sync_wait = 0;
CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB;
FLUSH TABLE t1 WITH READ LOCK;
--connection node_2
INSERT INTO t1 VALUES (1);
INSERT INTO t1 VALUES (2);
--connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1
--connection node_1a
SET SESSION wsrep_sync_wait = 0;
--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND STATE = 'Waiting for table metadata lock'
--source include/wait_condition.inc
SELECT COUNT(*) = 0 FROM t1;
--connection node_1
UNLOCK TABLES;
SET SESSION wsrep_sync_wait = 7;
SELECT COUNT(*) = 2 FROM t1;
DROP TABLE t1;
--lock_wait_timeout=5 --innodb_lock_wait_timeout=5 --wait_timeout=5
#
# Test that applying a DDL plays well with FLUSH TABLE table_name WITH READ LOCK. The applier
# thread should block until UNLOCK TABLEs.
#
--source include/galera_cluster.inc
--source include/have_innodb.inc
--connection node_1
SET SESSION wsrep_sync_wait = 0;
# Those values are valid only for connection node_1. The global values from the -master.opt file apply to applier threads.
SET SESSION lock_wait_timeout = 60;
SET SESSION innodb_lock_wait_timeout=60;
SET SESSION wait_timeout=60;
CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB;
FLUSH TABLE t1 WITH READ LOCK;
--connection node_2
ALTER TABLE t1 ADD COLUMN f2 INTEGER;
--connection node_1
SELECT 1 FROM DUAL;
# Sleep for longer than the global timeout ...
--sleep 6
SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND STATE = 'Waiting for table metadata lock';
UNLOCK TABLES;
SET SESSION wsrep_sync_wait = 7;
SHOW CREATE TABLE t1;
SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND STATE = 'Waiting for table metadata lock';
DROP TABLE t1;
--source include/galera_cluster.inc
--source include/have_innodb.inc
#
# Test that a local FLUSH TABLES FOR BACKUP will NOT be broken by an incoming remote transaction against that table
#
CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB;
--connection node_2
SET AUTOCOMMIT=OFF;
--let $wsrep_local_bf_aborts_before = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_bf_aborts'`
FLUSH TABLES t1 FOR EXPORT;
--connection node_1
INSERT INTO t1 VALUES (2);
--connection node_2
SET SESSION wsrep_sync_wait = 0;
--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND STATE = 'Waiting for table metadata lock'
--source include/wait_condition.inc
UNLOCK TABLES;
--let $wait_condition = SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND STATE = 'Waiting for table metadata lock'
--source include/wait_condition.inc
COMMIT;
SELECT COUNT(*) = 1 FROM t1;
--let $wsrep_local_bf_aborts_after = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_bf_aborts'`
--disable_query_log
--eval SELECT $wsrep_local_bf_aborts_after - $wsrep_local_bf_aborts_before = 0 AS wsrep_local_aborts_increment;
--enable_query_log
DROP TABLE t1;
......@@ -2,7 +2,7 @@
--source include/have_innodb.inc
#
# Test that a local LOCK TABLE will be broken by an incoming remote transaction against that table
# Test that a local LOCK TABLE will NOT be broken by an incoming remote transaction against that table
#
CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB;
......@@ -12,22 +12,25 @@ SET AUTOCOMMIT=OFF;
--let $wsrep_local_bf_aborts_before = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_bf_aborts'`
LOCK TABLE t1 WRITE;
# Issue a concurrent INSERT against the lock table that will block
--connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2
--send INSERT INTO t1 VALUES (1);
--connection node_1
INSERT INTO t1 VALUES (2);
# The concurent insert is allowed to complete because the LOCK TABLE is now broken
--connection node_2a
--error 0
--reap
--connection node_2
--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND STATE = 'Waiting for table metadata lock'
--source include/wait_condition.inc
UNLOCK TABLES;
--let $wait_condition = SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND STATE = 'Waiting for table metadata lock'
--source include/wait_condition.inc
COMMIT;
SELECT COUNT(*) = 1 FROM t1;
--let $wsrep_local_bf_aborts_after = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_bf_aborts'`
--disable_query_log
--eval SELECT $wsrep_local_bf_aborts_after - $wsrep_local_bf_aborts_before = 1 AS wsrep_local_aborts_increment;
--eval SELECT $wsrep_local_bf_aborts_after - $wsrep_local_bf_aborts_before = 0 AS wsrep_local_aborts_increment;
--enable_query_log
DROP TABLE t1;
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment