| 1 |
# |
| 2 |
# Test that a LOCK TABLE on the slave will cause all applier threads to block, |
| 3 |
# Even though the two INSERTS are independent transactions, the fact that t1 is locked |
| 4 |
# prevents the applier thread from committing the insert against t2, as commits are done |
| 5 |
# in order. |
| 6 |
# |
| 7 |
|
| 8 |
--source include/galera_cluster.inc |
| 9 |
--source include/have_innodb.inc |
| 10 |
|
| 11 |
CREATE TABLE t1 (id INT PRIMARY KEY) ENGINE=InnoDB; |
| 12 |
CREATE TABLE t2 (id INT PRIMARY KEY) ENGINE=InnoDB; |
| 13 |
|
| 14 |
--connection node_2 |
| 15 |
|
| 16 |
--let $wsrep_slave_threads_orig = `SELECT @@wsrep_slave_threads` |
| 17 |
--let $wsrep_sync_wait_orig = `SELECT @@wsrep_sync_wait` |
| 18 |
|
| 19 |
SET GLOBAL wsrep_slave_threads = 2; |
| 20 |
LOCK TABLE t1 READ; |
| 21 |
|
| 22 |
--connection node_1 |
| 23 |
INSERT INTO t1 VALUES (1); |
| 24 |
INSERT INTO t2 VALUES (1); |
| 25 |
|
| 26 |
# We use a separate connection here so that we can SELECT from both tables |
| 27 |
# without running into "table t2 was not locked" error. |
| 28 |
|
| 29 |
--let $galera_connection_name = node_2a |
| 30 |
--let $galera_server_number = 2 |
| 31 |
--source include/galera_connect.inc |
| 32 |
|
| 33 |
--connection node_2a |
| 34 |
--sleep 1 |
| 35 |
SET SESSION wsrep_sync_wait=0; |
| 36 |
SELECT COUNT(*) AS EXPECT_1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND (STATE LIKE '%committing%' OR STATE LIKE 'Commit' OR STATE LIKE 'Waiting for certification'); |
| 37 |
SELECT COUNT(*) AS EXPECT_1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND (STATE LIKE 'Waiting for table metadata lock%' OR STATE LIKE 'Waiting to execute in isolation%'); |
| 38 |
|
| 39 |
SELECT COUNT(*) AS EXPECT_0 FROM t1; |
| 40 |
SELECT COUNT(*) AS EXPECT_0 FROM t2; |
| 41 |
|
| 42 |
--connection node_2 |
| 43 |
UNLOCK TABLES; |
| 44 |
|
| 45 |
--connection node_2a |
| 46 |
--eval SET SESSION wsrep_sync_wait = $wsrep_sync_wait_orig; |
| 47 |
SELECT COUNT(*) AS EXPECT_1 FROM t1; |
| 48 |
SELECT COUNT(*) AS EXPECT_1 FROM t2; |
| 49 |
SELECT COUNT(*) AS EXPECT_2 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND (STATE LIKE '%committed%' OR STATE LIKE 'Waiting for certification'); |
| 50 |
|
| 51 |
--disable_query_log |
| 52 |
--eval SET GLOBAL wsrep_slave_threads = $wsrep_slave_threads_orig; |
| 53 |
--enable_query_log |
| 54 |
|
| 55 |
DROP TABLE t1; |
| 56 |
DROP TABLE t2; |