| 1 |
################################################################################ |
| 2 |
# This test proves that the server cannot start when the mysql.session |
| 3 |
# is not present. |
| 4 |
# |
| 5 |
# 0) Start with GR stopped in both servers |
| 6 |
# 1) Remove the mysql.session |
| 7 |
# 2) Start group replication and see the command errors out |
| 8 |
# 3) Restart the server and check the it errors out |
| 9 |
# 4) Restore the user |
| 10 |
# |
| 11 |
################################################################################ |
| 12 |
|
| 13 |
--source include/have_group_replication_plugin.inc |
| 14 |
--let $rpl_skip_group_replication_start= 1 |
| 15 |
--source include/group_replication.inc |
| 16 |
|
| 17 |
--echo # |
| 18 |
--echo # Delete the user and check the start fails |
| 19 |
--echo # |
| 20 |
|
| 21 |
--let $rpl_connection_name= server1 |
| 22 |
--source include/rpl_connection.inc |
| 23 |
|
| 24 |
#save user timestamps for later restore |
| 25 |
let $date_to_restore=`SELECT password_last_changed from mysql.user where user='mysql.session'`; |
| 26 |
let $date_to_restore_priv=`SELECT timestamp from mysql.tables_priv where user='mysql.session'`; |
| 27 |
USE test; |
| 28 |
CREATE TABLE test.tmp_user AS SELECT * FROM mysql.user; |
| 29 |
INSERT INTO tmp_user SELECT * FROM mysql.user; |
| 30 |
|
| 31 |
CREATE TABLE tmp_global_grants AS SELECT * FROM mysql.global_grants; |
| 32 |
INSERT INTO tmp_global_grants SELECT * FROM mysql.global_grants; |
| 33 |
|
| 34 |
DROP USER "mysql.session"@"localhost"; |
| 35 |
|
| 36 |
--replace_result $group_replication_group_name GROUP_REPLICATION_GROUP_NAME |
| 37 |
--eval SET GLOBAL group_replication_group_name= "$group_replication_group_name" |
| 38 |
|
| 39 |
--error ER_GROUP_REPLICATION_CONFIGURATION |
| 40 |
START GROUP_REPLICATION; |
| 41 |
|
| 42 |
--let $assert_text= Member 1 is OFFLINE |
| 43 |
--let $assert_cond= [SELECT COUNT(*) FROM performance_schema.replication_group_members WHERE member_state="OFFLINE"] = 1 |
| 44 |
--source include/assert.inc |
| 45 |
|
| 46 |
--let $assert_file= $MYSQLTEST_VARDIR/log/mysqld.1.err |
| 47 |
--let $assert_count = 1 |
| 48 |
--let $assert_select = There was an error when trying to access the server with user: mysql.session. Make |
| 49 |
--let $assert_text = Found the expected error about the missing user in server log |
| 50 |
--source include/assert_grep.inc |
| 51 |
|
| 52 |
--echo # |
| 53 |
--echo # Restart the server |
| 54 |
--echo # Check the plugin is not running |
| 55 |
--echo # |
| 56 |
|
| 57 |
--let $allow_rpl_inited=1 |
| 58 |
--let $_group_replication_local_address= `SELECT @@GLOBAL.group_replication_local_address` |
| 59 |
--let $_group_replication_group_seeds= `SELECT @@GLOBAL.group_replication_group_seeds` |
| 60 |
--let $restart_parameters=restart:--group_replication_local_address=$_group_replication_local_address --group_replication_group_seeds=$_group_replication_group_seeds --group_replication_start_on_boot=1 --group_replication_group_name=$group_replication_group_name |
| 61 |
--replace_result $_group_replication_local_address GROUP_REPLICATION_LOCAL_ADDRESS $_group_replication_group_seeds GROUP_REPLICATION_GROUP_SEEDS $group_replication_group_name GROUP_REPLICATION_GROUP_NAME |
| 62 |
--source include/restart_mysqld.inc |
| 63 |
|
| 64 |
--let $rpl_server_number= 1 |
| 65 |
--source include/rpl_reconnect.inc |
| 66 |
|
| 67 |
--let $assert_text= Member 1 is OFFLINE |
| 68 |
--let $assert_cond= [SELECT COUNT(*) FROM performance_schema.replication_group_members WHERE member_state="OFFLINE"] = 1 |
| 69 |
--source include/assert.inc |
| 70 |
|
| 71 |
--echo # |
| 72 |
--echo # Restore the user |
| 73 |
--echo # |
| 74 |
|
| 75 |
--disable_query_log |
| 76 |
--disable_result_log |
| 77 |
TRUNCATE TABLE mysql.user; |
| 78 |
INSERT IGNORE INTO mysql.user SELECT * FROM tmp_user; |
| 79 |
DROP TABLE tmp_user; |
| 80 |
|
| 81 |
TRUNCATE TABLE mysql.global_grants; |
| 82 |
INSERT IGNORE INTO mysql.global_grants SELECT * FROM tmp_global_grants; |
| 83 |
DROP TABLE tmp_global_grants; |
| 84 |
--enable_result_log |
| 85 |
|
| 86 |
--eval INSERT IGNORE INTO mysql.tables_priv VALUES ('localhost', 'mysql', 'mysql.session', 'user', 'root\@localhost', "$date_to_restore_priv", 'Select', ''); |
| 87 |
|
| 88 |
INSERT IGNORE INTO mysql.db VALUES ('localhost', 'performance_schema', 'mysql.session','Y','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N'); |
| 89 |
--enable_query_log |
| 90 |
|
| 91 |
FLUSH PRIVILEGES; |
| 92 |
|
| 93 |
--echo # |
| 94 |
--echo # Suppress errors |
| 95 |
--echo # |
| 96 |
|
| 97 |
SET SESSION sql_log_bin= 0; |
| 98 |
call mtr.add_suppression("There was an error when trying to access the server with user: mysql.session.*"); |
| 99 |
call mtr.add_suppression("Failed to establish an internal server connection to execute plugin operations"); |
| 100 |
call mtr.add_suppression("It was not possible to establish a connection to server SQL service"); |
| 101 |
call mtr.add_suppression("On plugin shutdown it was not possible to reset the server read mode settings."); |
| 102 |
SET SESSION sql_log_bin= 1; |
| 103 |
|
| 104 |
--let $_group_replication_local_address= `SELECT @@GLOBAL.group_replication_local_address` |
| 105 |
--let $_group_replication_group_seeds= `SELECT @@GLOBAL.group_replication_group_seeds` |
| 106 |
--let $restart_parameters=restart:--group_replication_local_address=$_group_replication_local_address --group_replication_group_seeds=$_group_replication_group_seeds --group_replication_start_on_boot=0 --group_replication_group_name=$group_replication_group_name |
| 107 |
--replace_result $_group_replication_local_address GROUP_REPLICATION_LOCAL_ADDRESS $_group_replication_group_seeds GROUP_REPLICATION_GROUP_SEEDS $group_replication_group_name GROUP_REPLICATION_GROUP_NAME |
| 108 |
--source include/restart_mysqld.inc |
| 109 |
--let $rpl_server_number= 1 |
| 110 |
--source include/rpl_reconnect.inc |
| 111 |
|
| 112 |
|
| 113 |
--source include/group_replication_end.inc |