Debian Codegraph @

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

raw
1 #
2 # This tests the very basic operations around wsrep-slave-threads
3 # More complex scenarios will be tested separately in the context of
4 # parallel replication
5 #
6
7 --source include/galera_cluster.inc
8 --source include/have_innodb.inc
9 --source include/force_restart.inc
10
11 # Save original auto_increment_offset values.
12 --let $node_1=node_1
13 --let $node_2=node_2
14 --source include/auto_increment_offset_save.inc
15
16 --connection node_1
17 --let $wsrep_slave_threads_orig = `SELECT @@wsrep_slave_threads`
18
19 CREATE TABLE t1 (f1 INT PRIMARY KEY) Engine=InnoDB;
20 CREATE TABLE t2 (f1 INT AUTO_INCREMENT PRIMARY KEY) Engine=InnoDB;
21
22 --connection node_2
23 --let $wsrep_slave_threads_orig_2 = `SELECT @@wsrep_slave_threads`
24
25 CALL mtr.add_suppression("WSREP: Refusing exit for the last slave thread\\.");
26
27 # Setting wsrep_slave_threads to zero triggers a warning
28 SET GLOBAL wsrep_slave_threads = 0;
29 SHOW WARNINGS;
30 SELECT @@wsrep_slave_threads = 1;
31
32 SET GLOBAL wsrep_slave_threads = 1;
33 # There is a separate wsrep_aborter thread at all times
34 SELECT COUNT(*) FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND STATE LIKE '%wsrep aborter%';
35
36 --connection node_1
37 INSERT INTO t1 VALUES (1);
38
39 --connection node_2
40
41 --let $wait_timeout=600
42 --let $wait_condition = SELECT COUNT(*) = 1 FROM t1;
43 --source include/wait_condition.inc
44
45 SELECT COUNT(*) FROM t1;
46
47 #
48 # Increase the number of slave threads. The change takes effect immediately
49 #
50 SET GLOBAL wsrep_slave_threads = 64;
51
52 --let $wait_condition = SELECT VARIABLE_VALUE = 64 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_applier_thread_count';
53 --source include/wait_condition.inc
54
55 #
56 # Reduce the number of slave threads. The change is not immediate -- a thread will only exit after a replication event
57 #
58
59 SET GLOBAL wsrep_slave_threads = 1;
60
61 --connection node_1
62
63 --disable_result_log
64 --disable_query_log
65 # Generate 70 replication events
66 --let $count = 70
67 while ($count)
68 {
69 INSERT INTO t2 VALUES (DEFAULT);
70 --dec $count
71 }
72 --enable_query_log
73 --enable_result_log
74
75 --connection node_2
76 SELECT COUNT(*) FROM t2;
77
78 --let $wait_condition = SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_applier_thread_count';
79 --source include/wait_condition.inc
80
81 --disable_query_log
82 --eval SET GLOBAL wsrep_slave_threads = $wsrep_slave_threads_orig_2;
83 --enable_query_log
84
85 DROP TABLE t1;
86 DROP TABLE t2;
87
88 --echo #
89 --echo # lp:1372840 - Changing wsrep_slave_threads causes future connections to hang
90 --echo #
91
92 --connection node_1
93 CREATE TABLE t1 (i INT AUTO_INCREMENT PRIMARY KEY) ENGINE=INNODB;
94
95 --connection node_2
96 SET GLOBAL wsrep_slave_threads = 4;
97 --let $wait_condition = SELECT VARIABLE_VALUE = 4 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_applier_thread_count';
98 --source include/wait_condition.inc
99
100 SET GLOBAL wsrep_slave_threads = 1;
101
102 --connection node_1
103
104 --disable_query_log
105 --eval SET GLOBAL wsrep_slave_threads = $wsrep_slave_threads_orig;
106 --enable_query_log
107
108 INSERT INTO t1 VALUES (DEFAULT);
109 INSERT INTO t1 VALUES (DEFAULT);
110 INSERT INTO t1 VALUES (DEFAULT);
111 INSERT INTO t1 VALUES (DEFAULT);
112 INSERT INTO t1 VALUES (DEFAULT);
113 INSERT INTO t1 VALUES (DEFAULT);
114 INSERT INTO t1 VALUES (DEFAULT);
115 INSERT INTO t1 VALUES (DEFAULT);
116 DROP TABLE t1;
117
118 --connection node_2
119
120 --disable_query_log
121 --eval SET GLOBAL wsrep_slave_threads = $wsrep_slave_threads_orig_2;
122 --enable_query_log
123
124 # Wait until above DDL is replicated
125 #
126 # make sure that we are left with exactly one applier thread before we leaving the test
127 #
128 --let $wait_condition = SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_applier_thread_count';
129 --source include/wait_condition.inc
130
131 SELECT NAME FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES WHERE NAME LIKE 'test/t%';
132
133 # Restore original auto_increment_offset values.
134 --source include/auto_increment_offset_restore.inc
135
136 --echo # End of tests