Debian Codegraph @

mysql-test/suite/galera/t/galera_lock_table.test

raw
1 #
2 # Test that a LOCK TABLE on the slave will cause the applier thread to block, so no subsequent updates
3 # are replicated on the slave until UNLOCK TABLE is issued.
4 #
5
6 --source include/galera_cluster.inc
7 --source include/have_innodb.inc
8
9 --let $wsrep_sync_wait_orig = `SELECT @@wsrep_sync_wait`
10
11 CREATE TABLE t1 (id INT PRIMARY KEY) ENGINE=InnoDB;
12 CREATE TABLE t2 (id INT PRIMARY KEY) ENGINE=InnoDB;
13
14 --sleep 1
15
16 --connection node_2
17
18 # Wait until above DDL's are replicated
19 --let $wait_condition = SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES WHERE NAME LIKE 'test/t%';
20 --source include/wait_condition.inc
21
22 SELECT NAME FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES WHERE NAME LIKE 'test/t%';
23
24 LOCK TABLE t1 READ;
25
26 --connection node_1
27 INSERT INTO t1 VALUES (1);
28 INSERT INTO t2 VALUES (1);
29
30 # We use a separate connection here so that we can SELECT from both tables
31 # without running into "table t2 was not locked" error.
32
33 --let $galera_connection_name = node_2a
34 --let $galera_server_number = 2
35 --source include/galera_connect.inc
36 --connection node_2a
37 SET SESSION wsrep_sync_wait=0;
38 SELECT COUNT(*) = 0 FROM t1;
39 SELECT COUNT(*) = 0 FROM t2;
40
41 --connection node_2
42 UNLOCK TABLES;
43
44 --disable_query_log
45 --eval SET SESSION wsrep_sync_wait=$wsrep_sync_wait_orig;
46 --enable_query_log
47
48 SELECT COUNT(*) = 1 FROM t1;
49 SELECT COUNT(*) = 1 FROM t2;
50
51 DROP TABLE t1;
52 DROP TABLE t2;