| 1 |
################################################################################ |
| 2 |
# The aim of this testcase is to test persisted behavior of replication |
| 3 |
# variables with SET PERSIST and RESET PERSIST IF EXISTS clauses. |
| 4 |
# |
| 5 |
# Test: |
| 6 |
# 0. Check that there are no persisted variable settings due to improper |
| 7 |
# cleanup by other testcases. |
| 8 |
# 1. Test SET PERSIST. Verify persisted variables. |
| 9 |
# 2. Restart server, it must preserve the persisted variable settings. |
| 10 |
# Verify persisted configuration. |
| 11 |
# 3. Test RESET PERSIST IF EXISTS. Verify persisted variable settings are |
| 12 |
# removed. |
| 13 |
# 4. Clean up. |
| 14 |
################################################################################ |
| 15 |
--source include/have_log_bin.inc |
| 16 |
--source include/have_semisync_plugin.inc |
| 17 |
# Test is agnostic to binlog_format. |
| 18 |
--source include/have_binlog_format_row.inc |
| 19 |
|
| 20 |
|
| 21 |
--echo ############################################################ |
| 22 |
--echo # 0. Check that there are no persisted variable settings. |
| 23 |
--let $assert_text = Expect 0 persisted variables. |
| 24 |
--let $assert_cond = [SELECT COUNT(*) as count FROM performance_schema.persisted_variables, count, 1] = 0 |
| 25 |
--source include/assert.inc |
| 26 |
|
| 27 |
|
| 28 |
--echo |
| 29 |
--echo ############################################################ |
| 30 |
--echo # 1. Initialization. Test SET PERSIST. Verify persisted |
| 31 |
--echo # variables. |
| 32 |
--let $MYSQLD_DATADIR= `select @@datadir;` |
| 33 |
CALL mtr.add_suppression("Unsafe statement written to the binary log"); |
| 34 |
|
| 35 |
--echo # Install semi-sync related plugins |
| 36 |
--replace_result $SEMISYNC_SOURCE_PLUGIN SEMISYNC_SOURCE_PLUGIN |
| 37 |
eval INSTALL PLUGIN rpl_semi_sync_source SONAME '$SEMISYNC_SOURCE_PLUGIN'; |
| 38 |
--replace_result $SEMISYNC_REPLICA_PLUGIN SEMISYNC_REPLICA_PLUGIN |
| 39 |
eval INSTALL PLUGIN rpl_semi_sync_replica SONAME '$SEMISYNC_REPLICA_PLUGIN'; |
| 40 |
|
| 41 |
CREATE TABLE rplvars (id INT PRIMARY KEY AUTO_INCREMENT, varname VARCHAR(64), varvalue VARCHAR(256)); |
| 42 |
# Disable warning to avoid printing of ER_BINLOG_UNSAFE_STATEMENT |
| 43 |
--disable_warnings |
| 44 |
INSERT INTO rplvars (varname, varvalue) |
| 45 |
SELECT * FROM performance_schema.global_variables |
| 46 |
WHERE (VARIABLE_NAME LIKE '%binlog%' OR |
| 47 |
VARIABLE_NAME LIKE '%gtid%' OR |
| 48 |
VARIABLE_NAME LIKE '%log_bin%' OR |
| 49 |
VARIABLE_NAME LIKE '%master%' OR |
| 50 |
VARIABLE_NAME LIKE '%relay%' OR |
| 51 |
VARIABLE_NAME LIKE '%replica%' OR |
| 52 |
VARIABLE_NAME LIKE '%rpl%' OR |
| 53 |
VARIABLE_NAME LIKE '%semi_sync%' OR |
| 54 |
VARIABLE_NAME LIKE '%slave%' OR |
| 55 |
VARIABLE_NAME LIKE '%source%') AND |
| 56 |
(VARIABLE_NAME NOT IN ('innodb_api_enable_binlog', |
| 57 |
'innodb_master_thread_disabled_debug', 'innodb_replication_delay')) |
| 58 |
ORDER BY VARIABLE_NAME; |
| 59 |
--enable_warnings |
| 60 |
--let $countvars = `SELECT COUNT(*) FROM rplvars;` |
| 61 |
|
| 62 |
# If this count differs, it means a variable has been added or removed. |
| 63 |
# In that case, this testcase needs to be updated accordingly. |
| 64 |
--echo |
| 65 |
--let $expected = 114 |
| 66 |
--let $assert_text = Expect $expected variables in the table. |
| 67 |
--let $assert_cond = [SELECT COUNT(*) as count FROM rplvars, count, 1] = $expected |
| 68 |
--source include/assert.inc |
| 69 |
|
| 70 |
--echo |
| 71 |
--echo # Test SET PERSIST |
| 72 |
--let $varid=1 |
| 73 |
while ( $varid <= $countvars ) |
| 74 |
{ |
| 75 |
--let $varnames = `SELECT varname FROM rplvars WHERE id=$varid;` |
| 76 |
|
| 77 |
# The following variables are either non persistent or read only variables. |
| 78 |
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_info_file', 'relay_log_recovery', 'relay_log_space_limit', 'replica_load_tmpdir', 'slave_load_tmpdir', 'replica_skip_errors', 'slave_skip_errors', 'log_bin_use_v1_row_events', 'binlog_rotate_encryption_master_key_at_startup', 'skip_replica_start', 'skip_slave_start')`) |
| 79 |
{ |
| 80 |
--error ER_INCORRECT_GLOBAL_LOCAL_VAR |
| 81 |
} |
| 82 |
--eval SET PERSIST $varnames = @@GLOBAL.$varnames |
| 83 |
|
| 84 |
--inc $varid |
| 85 |
} |
| 86 |
|
| 87 |
--echo |
| 88 |
--let $expected = 90 |
| 89 |
--let $assert_text = Expect $expected persisted variables in persisted_variables table. |
| 90 |
--let $assert_cond = [SELECT COUNT(*) as count FROM performance_schema.persisted_variables, count, 1] = $expected |
| 91 |
--source include/assert.inc |
| 92 |
|
| 93 |
--echo |
| 94 |
--echo ############################################################ |
| 95 |
--echo # 2. Restart server, it must preserve the persisted variable |
| 96 |
--echo # settings. Verify persisted configuration. |
| 97 |
--source include/restart_mysqld.inc |
| 98 |
--source include/wait_until_connected_again.inc |
| 99 |
|
| 100 |
--echo |
| 101 |
--let $assert_text = Expect $expected persisted variables in persisted_variables table.' |
| 102 |
--let $assert_cond = [SELECT COUNT(*) as count FROM performance_schema.persisted_variables, count, 1] = $expected |
| 103 |
--source include/assert.inc |
| 104 |
|
| 105 |
--let $assert_text = Expect $expected persisted variables shown as PERSISTED in variables_info table.' |
| 106 |
--let $assert_cond = [SELECT COUNT(*) as count FROM performance_schema.variables_info WHERE variable_source = "PERSISTED", count, 1] = $expected |
| 107 |
--source include/assert.inc |
| 108 |
|
| 109 |
--let $assert_text = Expect $expected persisted variables with matching persisted and global values. |
| 110 |
--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 |
| 111 |
--source include/assert.inc |
| 112 |
|
| 113 |
|
| 114 |
--echo |
| 115 |
--echo ############################################################ |
| 116 |
--echo # 3. Test RESET PERSIST IF EXISTS. Verify persisted variable |
| 117 |
--echo # settings are removed. |
| 118 |
--let $varid=1 |
| 119 |
while ( $varid <= $countvars ) |
| 120 |
{ |
| 121 |
--let $varnames= `SELECT varname FROM rplvars WHERE id=$varid` |
| 122 |
--eval RESET PERSIST IF EXISTS $varnames |
| 123 |
--inc $varid |
| 124 |
} |
| 125 |
|
| 126 |
--echo |
| 127 |
--let $assert_text = Expect 0 persisted variables. |
| 128 |
--let $assert_cond = [SELECT COUNT(*) as count FROM performance_schema.persisted_variables, count, 1] = 0 |
| 129 |
--source include/assert.inc |
| 130 |
|
| 131 |
--echo |
| 132 |
--echo ############################################################ |
| 133 |
--echo # 4. Clean up. |
| 134 |
--let $countvars= |
| 135 |
--let $varid= |
| 136 |
--let $varnames= |
| 137 |
--remove_file $MYSQLD_DATADIR/mysqld-auto.cnf |
| 138 |
UNINSTALL PLUGIN rpl_semi_sync_source; |
| 139 |
UNINSTALL PLUGIN rpl_semi_sync_replica; |
| 140 |
DROP TABLE rplvars; |