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
|
################################################################################
# This test is to verify that group replication variables are persisted into
# mysqld-auto.cnf file, and, server can restart successfully using this file.
#
# Test:
# 0. The test requires one server. Check that there are no persisted variables.
# 1. Test SET PERSIST. Verify persisted variables.
# 2. Restart server, it must bootstrap the group and preserve the persisted
# variables setting. Verify persisted configuration.
# 3. Test RESET PERSIST. Verify that there are no persisted variables.
# 4. Clean up.
################################################################################
--source include/big_test.inc
--source include/have_group_replication_xcom_communication_stack.inc
--source include/have_group_replication_plugin.inc
--let $rpl_skip_group_replication_start= 1
--source include/group_replication.inc
--echo
--echo ############################################################
--echo # 0. Check that there are no persisted variables.
--let $rpl_connection_name= server1
--source include/rpl_connection.inc
--let $assert_text= 'Expect 1 persisted variables.'
--let $assert_cond= [SELECT COUNT(*) as count FROM performance_schema.persisted_variables, count, 1] = 1
--source include/assert.inc
--echo
--echo ############################################################
--echo # 1. Test SET PERSIST. Verify persisted variables.
--replace_result $group_replication_group_name GROUP_REPLICATION_GROUP_NAME
--eval SET GLOBAL group_replication_group_name= "$group_replication_group_name"
SET GLOBAL group_replication_start_on_boot= ON;
SET GLOBAL group_replication_bootstrap_group= ON;
CREATE TABLE grvars (id INT PRIMARY KEY AUTO_INCREMENT, varname VARCHAR(64), varvalue VARCHAR(256));
INSERT INTO grvars (varname, varvalue)
SELECT * FROM performance_schema.global_variables
WHERE VARIABLE_NAME LIKE '%group_replication%'
AND VARIABLE_NAME NOT LIKE 'group_replication_force_members'
ORDER BY VARIABLE_NAME;
--let $countvars= `SELECT COUNT(*) FROM grvars;`
--echo
--let $varid=1
while ( $varid <= $countvars )
{
--let $varnames= `SELECT varname FROM grvars WHERE id=$varid`
--eval SET PERSIST $varnames = @@GLOBAL.$varnames
--inc $varid
}
--echo
--let $assert_text= 'Expect $countvars persisted variables.'
--let $assert_cond= [SELECT COUNT(*) as count FROM performance_schema.persisted_variables, count, 1] = $countvars
--source include/assert.inc
--echo
--echo ############################################################
--echo # 2. Restart server, it must bootstrap the group and preserve
--echo # the persisted settings. Verify persisted configuration.
--let $allow_rpl_inited= 1
--source include/restart_mysqld.inc
--let $rpl_server_number= 1
--source include/rpl_reconnect.inc
--let $MYSQLD_DATADIR= `select @@datadir;`
--let $group_replication_member_state= ONLINE
--source include/gr_wait_for_member_state.inc
--echo
--let $assert_text= 'Expect $countvars persisted variables in persisted_variables table.'
--let $assert_cond= [SELECT COUNT(*) as count FROM performance_schema.persisted_variables, count, 1] = $countvars
--source include/assert.inc
# Table performance_schema.variables_info shows, for each system
# variable, the source from which it was most recently set.
# Since GR does `SET SESSION group_replication_consistency= EVENTUAL;`
# on its SQL API internal connections, this option is shown as DYNAMIC
# instead of PERSISTED on performance_schema.variables_info table,
# despite being listed on performance_schema.persisted_variables table.
--let $countvars_excluding_group_replication_consistency= $countvars
--dec $countvars_excluding_group_replication_consistency
--let $assert_text= 'Expect $countvars_excluding_group_replication_consistency variables which last value was set through SET PERSIST.'
--let $assert_cond= [SELECT COUNT(*) as count FROM performance_schema.variables_info WHERE variable_source="PERSISTED", count, 1] = $countvars_excluding_group_replication_consistency
--source include/assert.inc
--let $assert_text= 'Expect $countvars_excluding_group_replication_consistency variables which last value was set through SET PERSIST is equal to its global value.'
--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] = $countvars_excluding_group_replication_consistency
--source include/assert.inc
--echo
--echo ############################################################
--echo # 3. Test RESET PERSIST.
--echo # Verify that there are no persisted variables.
--let $varid=1
while ( $varid <= $countvars )
{
--let $varnames= `SELECT varname FROM grvars WHERE id=$varid`
--eval RESET PERSIST $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
SET GLOBAL group_replication_start_on_boot= OFF;
SET GLOBAL group_replication_bootstrap_group= OFF;
DROP TABLE grvars;
--source include/group_replication_end.inc
|