| 1 |
################################################################################ |
| 2 |
# Validate that when a member joins a group, if the recovery user does not have |
| 3 |
# clone privileges, recovery by binary logs will be used subsequently. |
| 4 |
# |
| 5 |
# Test: |
| 6 |
# 0. The test requires two servers: M1 and M2. |
| 7 |
# 1. Install clone plugin on server1. |
| 8 |
# Create a recovery user without clone privileges. |
| 9 |
# Bootstrap a group on server1. |
| 10 |
# 2. Install clone plugin on server2. |
| 11 |
# Restart server with a monitoring process (mysqld_safe) if needed |
| 12 |
# 3. Start group replication using the created user credentials |
| 13 |
# GR will attempt to clone a donor but due to the lack of |
| 14 |
# privileges, recovery by binary logs will be used subsequently. |
| 15 |
# 4. Cleanup |
| 16 |
# |
| 17 |
|
| 18 |
--source include/have_mysqld_monitoring_process.inc |
| 19 |
--source include/have_clone_plugin.inc |
| 20 |
--source include/force_restart.inc |
| 21 |
--let $rpl_privilege_checks_user_grant_option = 1 |
| 22 |
--source include/set_privilege_checks_user_as_system_user.inc |
| 23 |
--source include/have_group_replication_plugin.inc |
| 24 |
--let $rpl_skip_group_replication_start= 1 |
| 25 |
--source include/group_replication.inc |
| 26 |
|
| 27 |
# Validate plugins |
| 28 |
--let plugins = CLONE_PLUGIN,GROUP_REPLICATION |
| 29 |
--source include/check_plugin_dir.inc |
| 30 |
|
| 31 |
--echo |
| 32 |
--echo ############################################################ |
| 33 |
--echo # 1. Install clone plugin on server1. |
| 34 |
--echo # Create a recovery user without clone privileges. |
| 35 |
--echo # Bootstrap a group on server1. |
| 36 |
--let $rpl_connection_name= server1 |
| 37 |
--source include/rpl_connection.inc |
| 38 |
|
| 39 |
# Install the clone plugin |
| 40 |
--replace_result $CLONE_PLUGIN CLONE_PLUGIN |
| 41 |
--eval INSTALL PLUGIN clone SONAME '$CLONE_PLUGIN' |
| 42 |
|
| 43 |
# Create a recovery user without clone privileges. |
| 44 |
SET SESSION sql_log_bin= 0; |
| 45 |
--let $recovery_user= recovery_user |
| 46 |
--let $recovery_password= recovery_password |
| 47 |
--eval CREATE USER "$recovery_user" IDENTIFIED BY "$recovery_password" |
| 48 |
--eval GRANT REPLICATION SLAVE ON *.* TO "$recovery_user" |
| 49 |
--eval GRANT GROUP_REPLICATION_STREAM ON *.* TO "$recovery_user"@'%'; |
| 50 |
FLUSH PRIVILEGES; |
| 51 |
SET SESSION sql_log_bin= 1; |
| 52 |
|
| 53 |
# Add some data for recovery |
| 54 |
CREATE TABLE t1 (c1 INT NOT NULL PRIMARY KEY) ENGINE=InnoDB; |
| 55 |
INSERT INTO t1 VALUES (1); |
| 56 |
INSERT INTO t1 VALUES (2); |
| 57 |
|
| 58 |
--source include/start_and_bootstrap_group_replication.inc |
| 59 |
|
| 60 |
--echo |
| 61 |
--echo ##################################################################### |
| 62 |
--echo # 2. Install clone plugin on server2. |
| 63 |
--echo # Restart server with a monitoring process (mysqld_safe) if needed |
| 64 |
|
| 65 |
# Install the clone plugin |
| 66 |
--let $rpl_connection_name= server2 |
| 67 |
--source include/rpl_connection.inc |
| 68 |
|
| 69 |
SET SESSION sql_log_bin= 0; |
| 70 |
--eval CREATE USER "$recovery_user" IDENTIFIED BY "$recovery_password" |
| 71 |
--eval GRANT GROUP_REPLICATION_STREAM ON *.* TO "$recovery_user"@'%'; |
| 72 |
FLUSH PRIVILEGES; |
| 73 |
SET SESSION sql_log_bin= 1; |
| 74 |
|
| 75 |
--replace_result $CLONE_PLUGIN CLONE_PLUGIN |
| 76 |
--eval INSTALL PLUGIN clone SONAME '$CLONE_PLUGIN' |
| 77 |
|
| 78 |
# Deal with server 2 that needs mysql safe |
| 79 |
--let $_group_replication_local_address= `SELECT @@GLOBAL.group_replication_local_address` |
| 80 |
--let $_group_replication_group_seeds= `SELECT @@GLOBAL.group_replication_group_seeds` |
| 81 |
--let $_group_replication_comm_stack= `SELECT @@GLOBAL.group_replication_communication_stack` |
| 82 |
--let $plugin_list= $GROUP_REPLICATION |
| 83 |
--source include/spawn_monitoring_process.inc |
| 84 |
|
| 85 |
# Configure GR for starting now and after restart |
| 86 |
--disable_query_log |
| 87 |
--eval SET PERSIST group_replication_group_name= "$group_replication_group_name" |
| 88 |
--eval SET PERSIST group_replication_local_address= "$_group_replication_local_address" |
| 89 |
--eval SET PERSIST group_replication_group_seeds= "$_group_replication_group_seeds" |
| 90 |
--eval SET PERSIST group_replication_communication_stack= "$_group_replication_comm_stack" |
| 91 |
SET PERSIST group_replication_start_on_boot= ON; |
| 92 |
--enable_query_log |
| 93 |
|
| 94 |
--echo |
| 95 |
--echo ##################################################################### |
| 96 |
--echo # 3. Start group replication using the created user credentials |
| 97 |
--echo # GR will attempt to clone a donor but due to the lack of |
| 98 |
--echo # privileges, recovery by binary logs will be used subsequently. |
| 99 |
|
| 100 |
--disable_warnings |
| 101 |
--eval CHANGE REPLICATION SOURCE TO SOURCE_USER='$recovery_user', SOURCE_PASSWORD='$recovery_password' FOR CHANNEL 'group_replication_recovery' |
| 102 |
--enable_warnings |
| 103 |
|
| 104 |
SET GLOBAL group_replication_clone_threshold= 1; |
| 105 |
--source include/start_group_replication.inc |
| 106 |
|
| 107 |
--let $assert_text= Clone status must be Failed |
| 108 |
--let $assert_cond= [SELECT state="Failed" FROM performance_schema.clone_status] = 1; |
| 109 |
--source include/assert.inc |
| 110 |
|
| 111 |
--let $assert_text= Clone error message must be access denied |
| 112 |
--let $assert_cond= [SELECT error_message="Clone Donor Error: 1227 : Access denied; you need (at least one of) the BACKUP_ADMIN privilege(s) for this operation." FROM performance_schema.clone_status] = 1; |
| 113 |
--source include/assert.inc |
| 114 |
|
| 115 |
--let $diff_tables= server1:test.t1, server2:test.t1 |
| 116 |
--source include/diff_tables.inc |
| 117 |
|
| 118 |
--echo |
| 119 |
--echo ############################################################ |
| 120 |
--echo # 4. Cleanup. |
| 121 |
--let $rpl_connection_name= server2 |
| 122 |
--source include/rpl_connection.inc |
| 123 |
|
| 124 |
RESET PERSIST IF EXISTS group_replication_group_name; |
| 125 |
RESET PERSIST IF EXISTS group_replication_local_address; |
| 126 |
RESET PERSIST IF EXISTS group_replication_group_seeds; |
| 127 |
RESET PERSIST IF EXISTS group_replication_start_on_boot; |
| 128 |
RESET PERSIST IF EXISTS group_replication_communication_stack; |
| 129 |
|
| 130 |
DROP TABLE t1; |
| 131 |
--eval DROP USER "$recovery_user" |
| 132 |
--source include/rpl_sync.inc |
| 133 |
|
| 134 |
SET SESSION sql_log_bin=0; |
| 135 |
call mtr.add_suppression("This member will start distributed recovery using clone. It is due to the number of missing transactions being higher than the configured threshold of 1."); |
| 136 |
call mtr.add_suppression("Internal query: CLONE INSTANCE FROM \'recovery_user\'@\'127.0.0.1\':[0-9]+ IDENTIFIED BY \'\\*\\*\\*\\*\\*\' REQUIRE NO SSL; result in error. Error number:*"); |
| 137 |
call mtr.add_suppression("There was an issue when cloning from another server: Error number: 3862 Error message: Clone Donor Error: 1227 : Access denied; you need \\(at least one of\\) the BACKUP_ADMIN privilege\\(s\\) for this operation."); |
| 138 |
call mtr.add_suppression("Due to some issue on the previous step distributed recovery is now executing: Incremental Recovery"); |
| 139 |
call mtr.add_suppression("Clone removing all user data for provisioning: Started"); |
| 140 |
call mtr.add_suppression("Clone removing all user data for provisioning: Finished"); |
| 141 |
SET SESSION sql_log_bin=1; |
| 142 |
|
| 143 |
--source include/clean_monitoring_process.inc |
| 144 |
|
| 145 |
--source include/group_replication_end.inc |