-
Notifications
You must be signed in to change notification settings - Fork 4k
/
Copy pathbinlog_persist_variables.test
140 lines (121 loc) · 6.14 KB
/
binlog_persist_variables.test
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
137
138
139
140
################################################################################
# The aim of this testcase is to test persisted behavior of replication
# variables with SET PERSIST and RESET PERSIST IF EXISTS clauses.
#
# Test:
# 0. Check that there are no persisted variable settings due to improper
# cleanup by other testcases.
# 1. Test SET PERSIST. Verify persisted variables.
# 2. Restart server, it must preserve the persisted variable settings.
# Verify persisted configuration.
# 3. Test RESET PERSIST IF EXISTS. Verify persisted variable settings are
# removed.
# 4. Clean up.
################################################################################
--source include/have_log_bin.inc
--source include/have_semisync_plugin.inc
# Test is agnostic to binlog_format.
--source include/have_binlog_format_row.inc
--echo ############################################################
--echo # 0. Check that there are no persisted variable settings.
--let $assert_text = Expect 0 persisted variables.
--let $assert_cond = [SELECT COUNT(*) as count FROM performance_schema.persisted_variables, count, 1] = 0
--source include/assert.inc
--echo
--echo ############################################################
--echo # 1. Initialization. Test SET PERSIST. Verify persisted
--echo # variables.
--let $MYSQLD_DATADIR= `select @@datadir;`
CALL mtr.add_suppression("Unsafe statement written to the binary log");
--echo # Install semi-sync related plugins
--replace_result $SEMISYNC_SOURCE_PLUGIN SEMISYNC_SOURCE_PLUGIN
eval INSTALL PLUGIN rpl_semi_sync_source SONAME '$SEMISYNC_SOURCE_PLUGIN';
--replace_result $SEMISYNC_REPLICA_PLUGIN SEMISYNC_REPLICA_PLUGIN
eval INSTALL PLUGIN rpl_semi_sync_replica SONAME '$SEMISYNC_REPLICA_PLUGIN';
CREATE TABLE rplvars (id INT PRIMARY KEY AUTO_INCREMENT, varname VARCHAR(64), varvalue VARCHAR(256));
# Disable warning to avoid printing of ER_BINLOG_UNSAFE_STATEMENT
--disable_warnings
INSERT INTO rplvars (varname, varvalue)
SELECT * FROM performance_schema.global_variables
WHERE (VARIABLE_NAME LIKE '%binlog%' OR
VARIABLE_NAME LIKE '%gtid%' OR
VARIABLE_NAME LIKE '%log_bin%' OR
VARIABLE_NAME LIKE '%master%' OR
VARIABLE_NAME LIKE '%relay%' OR
VARIABLE_NAME LIKE '%replica%' OR
VARIABLE_NAME LIKE '%rpl%' OR
VARIABLE_NAME LIKE '%semi_sync%' OR
VARIABLE_NAME LIKE '%slave%' OR
VARIABLE_NAME LIKE '%source%') AND
(VARIABLE_NAME NOT IN ('innodb_api_enable_binlog',
'innodb_master_thread_disabled_debug', 'innodb_replication_delay'))
ORDER BY VARIABLE_NAME;
--enable_warnings
--let $countvars = `SELECT COUNT(*) FROM rplvars;`
# If this count differs, it means a variable has been added or removed.
# In that case, this testcase needs to be updated accordingly.
--echo
--let $expected = 108
--let $assert_text = Expect $expected variables in the table.
--let $assert_cond = [SELECT COUNT(*) as count FROM rplvars, count, 1] = $expected
--source include/assert.inc
--echo
--echo # Test SET PERSIST
--let $varid=1
while ( $varid <= $countvars )
{
--let $varnames = `SELECT varname FROM rplvars WHERE id=$varid;`
# The following variables are either non persistent or read only variables.
if (`SELECT '$varnames' IN ('binlog_row_event_max_size', 'binlog_gtid_simple_recovery', 'gtid_executed', 'gtid_next', 'gtid_owned', 'gtid_purged', 'log_bin', 'log_bin_basename', 'log_bin_index', 'log_replica_updates', 'log_slave_updates', 'relay_log', 'relay_log_basename', 'relay_log_index', 'relay_log_index', 'relay_log_recovery', 'relay_log_space_limit', 'replica_load_tmpdir', 'slave_load_tmpdir', 'replica_skip_errors', 'slave_skip_errors', 'binlog_rotate_encryption_master_key_at_startup', 'skip_replica_start', 'skip_slave_start')`)
{
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
}
--eval SET PERSIST $varnames = @@GLOBAL.$varnames
--inc $varid
}
--echo
--let $expected = 86
--let $assert_text = Expect $expected persisted variables in persisted_variables table.
--let $assert_cond = [SELECT COUNT(*) as count FROM performance_schema.persisted_variables, count, 1] = $expected
--source include/assert.inc
--echo
--echo ############################################################
--echo # 2. Restart server, it must preserve the persisted variable
--echo # settings. Verify persisted configuration.
--source include/restart_mysqld.inc
--source include/wait_until_connected_again.inc
--echo
--let $assert_text = Expect $expected persisted variables in persisted_variables table.'
--let $assert_cond = [SELECT COUNT(*) as count FROM performance_schema.persisted_variables, count, 1] = $expected
--source include/assert.inc
--let $assert_text = Expect $expected persisted variables shown as PERSISTED in variables_info table.'
--let $assert_cond = [SELECT COUNT(*) as count FROM performance_schema.variables_info WHERE variable_source = "PERSISTED", count, 1] = $expected
--source include/assert.inc
--let $assert_text = Expect $expected persisted variables with matching persisted and global values.
--let $assert_cond = [SELECT COUNT(*) as count FROM performance_schema.variables_info vi JOIN performance_schema.persisted_variables pv JOIN performance_schema.global_variables gv ON vi.variable_name=pv.variable_name AND vi.variable_name=gv.variable_name AND pv.variable_value=gv.variable_value WHERE vi.variable_source="PERSISTED", count, 1] = $expected
--source include/assert.inc
--echo
--echo ############################################################
--echo # 3. Test RESET PERSIST IF EXISTS. Verify persisted variable
--echo # settings are removed.
--let $varid=1
while ( $varid <= $countvars )
{
--let $varnames= `SELECT varname FROM rplvars WHERE id=$varid`
--eval RESET PERSIST IF EXISTS $varnames
--inc $varid
}
--echo
--let $assert_text = Expect 0 persisted variables.
--let $assert_cond = [SELECT COUNT(*) as count FROM performance_schema.persisted_variables, count, 1] = 0
--source include/assert.inc
--echo
--echo ############################################################
--echo # 4. Clean up.
--let $countvars=
--let $varid=
--let $varnames=
--remove_file $MYSQLD_DATADIR/mysqld-auto.cnf
UNINSTALL PLUGIN rpl_semi_sync_source;
UNINSTALL PLUGIN rpl_semi_sync_replica;
DROP TABLE rplvars;