File: galera_var_slave_threads.test

package info (click to toggle)
mariadb 1%3A11.8.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, trixie
  • size: 765,428 kB
  • sloc: ansic: 2,382,827; cpp: 1,803,532; asm: 378,315; perl: 63,176; sh: 46,496; pascal: 40,776; java: 39,363; yacc: 20,428; python: 19,506; sql: 17,864; xml: 12,463; ruby: 8,544; makefile: 6,059; cs: 5,855; ada: 1,700; lex: 1,193; javascript: 1,039; objc: 80; tcl: 73; awk: 46; php: 22
file content (136 lines) | stat: -rw-r--r-- 3,889 bytes parent folder | download | duplicates (3)
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#
# 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
--source include/force_restart.inc

# Save original auto_increment_offset values.
--let $node_1=node_1
--let $node_2=node_2
--source include/auto_increment_offset_save.inc

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

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

--connection node_2
--let $wsrep_slave_threads_orig_2 = `SELECT @@wsrep_slave_threads`

CALL mtr.add_suppression("WSREP: Refusing exit for the last slave thread\\.");

# 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(*) FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND STATE LIKE '%wsrep aborter%';

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

--connection node_2

--let $wait_timeout=600
--let $wait_condition = SELECT COUNT(*) = 1 FROM t1;
--source include/wait_condition.inc

SELECT COUNT(*) FROM t1;

#
# Increase the number of slave threads. The change takes effect immediately
#
SET GLOBAL wsrep_slave_threads = 64;

--let $wait_condition = SELECT VARIABLE_VALUE = 64 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_applier_thread_count';
--source include/wait_condition.inc

#
# 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

--disable_result_log
--disable_query_log
# Generate 70 replication events
--let $count = 70
while ($count)
{
  INSERT INTO t2 VALUES (DEFAULT);
  --dec $count
}
--enable_query_log
--enable_result_log

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

--let $wait_condition = SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_applier_thread_count';
--source include/wait_condition.inc

--disable_query_log
--eval SET GLOBAL wsrep_slave_threads = $wsrep_slave_threads_orig_2;
--enable_query_log

DROP TABLE t1;
DROP TABLE t2;

--echo #
--echo # lp:1372840 - Changing wsrep_slave_threads causes future connections to hang
--echo #

--connection node_1
CREATE TABLE t1 (i INT AUTO_INCREMENT PRIMARY KEY) ENGINE=INNODB;

--connection node_2
SET GLOBAL wsrep_slave_threads = 4;
--let $wait_condition = SELECT VARIABLE_VALUE = 4 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_applier_thread_count';
--source include/wait_condition.inc

SET GLOBAL wsrep_slave_threads = 1;

--connection node_1

--disable_query_log
--eval SET GLOBAL wsrep_slave_threads = $wsrep_slave_threads_orig;
--enable_query_log

INSERT INTO t1 VALUES (DEFAULT);
INSERT INTO t1 VALUES (DEFAULT);
INSERT INTO t1 VALUES (DEFAULT);
INSERT INTO t1 VALUES (DEFAULT);
INSERT INTO t1 VALUES (DEFAULT);
INSERT INTO t1 VALUES (DEFAULT);
INSERT INTO t1 VALUES (DEFAULT);
INSERT INTO t1 VALUES (DEFAULT);
DROP TABLE t1;

--connection node_2

--disable_query_log
--eval SET GLOBAL wsrep_slave_threads = $wsrep_slave_threads_orig_2;
--enable_query_log

# Wait until above DDL is replicated
#
# make sure that we are left with exactly one applier thread before we leaving the test
#
--let $wait_condition = SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_applier_thread_count';
--source include/wait_condition.inc

SELECT NAME FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES WHERE NAME LIKE 'test/t%';

# Restore original auto_increment_offset values.
--source include/auto_increment_offset_restore.inc

--echo # End of tests