summaryrefslogtreecommitdiff
path: root/mysql-test/suite/galera/t/galera_var_slave_threads.test
blob: a83924c13ceb1a50f5580acad5e98af83964fca5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#
# This tests the very basic operations around wsrep-slave-threads
# More complex scenarios will be tested separately in the context of
# parallel replication
#

--source include/galera_cluster.inc
--source include/have_innodb.inc

--let $wsrep_slave_threads_orig = `SELECT @@wsrep_slave_threads`

--connection node_1
CREATE TABLE t1 (f1 INT PRIMARY KEY) Engine=InnoDB;
CREATE TABLE t2 (f1 INT AUTO_INCREMENT PRIMARY KEY) Engine=InnoDB;

--connection node_2

# Setting wsrep_slave_threads to zero triggers a warning
SET GLOBAL wsrep_slave_threads = 0;
SHOW WARNINGS;
SELECT @@wsrep_slave_threads = 1;

SET GLOBAL wsrep_slave_threads = 1;
# There is a separate wsrep_aborter thread at all times
SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user';
SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND STATE LIKE '%wsrep aborter%';

#
# Increase the number of slave threads. The change takes effect immediately
#

SET GLOBAL wsrep_slave_threads = 64;
--sleep 0.5

--connection node_1
INSERT INTO t1 VALUES (1);

--connection node_2
SELECT COUNT(*) = 1 FROM t1;

SELECT COUNT(*) = @@wsrep_slave_threads + 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user';
SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND STATE LIKE '%wsrep aborter%';

#
# Reduce the number of slave threads. The change is not immediate -- a thread will only exit after a replication event
#

SET GLOBAL wsrep_slave_threads = 1;

--connection node_1

# Generate 64 replication events
--let $count = 64
while ($count)
{
  INSERT INTO t2 VALUES (DEFAULT);
  --dec $count
}

--connection node_2
SELECT COUNT(*) = 64 FROM t2;

SELECT COUNT(*) = @@wsrep_slave_threads + 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user';
SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND STATE LIKE '%wsrep aborter%';


--eval SET GLOBAL wsrep_slave_threads = $wsrep_slave_threads_orig

DROP TABLE t1;
DROP TABLE t2;