Debian Codegraph @

mysql-test/suite/group_replication/t/gr_clone_applier_reset.test

raw
1 ###############################################################################
2 # This test proves Group replication does not delete group_replication_applier
3 # channel on start of group replication post clone.
4 #
5 # Test:
6 # 0. The test requires two servers: M1 and M2.
7 # 1. Install clone plugin on server1.
8 # 2. Set PRIVILEGE_CHECKS_USER for GR applier channel and recovery channels.
9 # Bootstrap server1 and add some data.
10 # 3. Restart server 2 with a monitoring process (mysqld_safe) if needed.
11 # 4. Setup the server so group replication starts on boot.
12 # Install the Clone plugin and set threshold to 1.
13 # 5. Start GR and wait for server to reboot post clone.
14 # Joiner must fail to join the group.
15 # 6. Confirm value of PRIVILEGE_CHECKS_USER is preserved pre and post GR start.
16 # 7. Cleanup.
17 ###############################################################################
18 --source include/have_mysqld_monitoring_process.inc
19 --source include/have_clone_plugin.inc
20 --source include/force_restart.inc
21 --source include/have_group_replication_plugin.inc
22 --let $rpl_skip_group_replication_start= 1
23 --source include/group_replication.inc
24
25 # Validate plugins
26 --let plugins = CLONE_PLUGIN,GROUP_REPLICATION
27 --source include/check_plugin_dir.inc
28
29
30 --echo
31 --echo # 1. Install clone plugin on server1.
32 --echo
33
34 --let $rpl_connection_name= server1
35 --source include/rpl_connection.inc
36
37 --replace_result $CLONE_PLUGIN CLONE_PLUGIN
38 --eval INSTALL PLUGIN clone SONAME '$CLONE_PLUGIN'
39
40 --echo
41 --echo # 2. Set PRIVILEGE_CHECKS_USER for GR applier channel and recovery channels.
42 --echo # Bootstrap server1 and add some data.
43 --echo
44
45 CHANGE REPLICATION SOURCE TO PRIVILEGE_CHECKS_USER = 'root'@'localhost' FOR CHANNEL "group_replication_applier";
46 CHANGE REPLICATION SOURCE TO SOURCE_USER="root", PRIVILEGE_CHECKS_USER = 'root'@'localhost' FOR CHANNEL "group_replication_recovery";
47
48 --source include/start_and_bootstrap_group_replication.inc
49
50 CREATE TABLE t1 (c1 INT NOT NULL PRIMARY KEY) ENGINE=InnoDB;
51 INSERT INTO t1 VALUES (1);
52 INSERT INTO t1 VALUES (2);
53
54 --echo
55 --echo # 3. Restart server 2 with a monitoring process (mysqld_safe) if needed.
56 --echo
57
58 --let $rpl_connection_name= server2
59 --source include/rpl_connection.inc
60
61 --let $_group_replication_local_address= `SELECT @@GLOBAL.group_replication_local_address`
62 --let $_group_replication_group_seeds= `SELECT @@GLOBAL.group_replication_group_seeds`
63 --let $_group_replication_comm_stack= `SELECT @@GLOBAL.group_replication_communication_stack`
64
65 --let $plugin_list= $GROUP_REPLICATION
66 --source include/spawn_monitoring_process.inc
67
68 --echo
69 --echo # 4. Setup the server so group replication starts on boot.
70 --echo # Install the Clone plugin and set threshold to 1.
71 --echo
72
73 --disable_query_log
74 --eval SET PERSIST group_replication_group_name= "$group_replication_group_name"
75 --eval SET PERSIST group_replication_local_address= "$_group_replication_local_address"
76 --eval SET PERSIST group_replication_group_seeds= "$_group_replication_group_seeds"
77 --eval SET PERSIST group_replication_communication_stack= "$_group_replication_comm_stack"
78
79
80 SET PERSIST group_replication_start_on_boot= OFF;
81 --enable_query_log
82
83 --replace_result $CLONE_PLUGIN CLONE_PLUGIN
84 --eval INSTALL PLUGIN clone SONAME '$CLONE_PLUGIN'
85 SET GLOBAL group_replication_clone_threshold= 1;
86 --let $_group_replication_threshold_save= `SELECT @@GLOBAL.group_replication_clone_threshold`
87
88 --echo
89 --echo # 5. Start GR and wait for server to reboot post clone.
90 --echo # Joiner must fail to join the group.
91 --echo
92
93 START GROUP_REPLICATION;
94
95 --source include/wait_until_disconnected.inc
96
97 --let $rpl_server_number= 2
98 --source include/rpl_reconnect.inc
99
100 --echo
101 --echo # 6. Confirm value of PRIVILEGE_CHECKS_USER is preserved pre and post GR start.
102 --echo
103
104 --let $pcu_count = `SELECT COUNT(*) FROM performance_schema.replication_applier_configuration WHERE CHANNEL_NAME= "group_replication_applier" AND PRIVILEGE_CHECKS_USER = "'root'@'localhost'"`
105 --let $assert_text= PRIVILEGE_CHECKS_USER has correct value for channel group_replication_applier
106 --let $assert_cond= $pcu_count = 1
107 --source include/assert.inc
108
109 --source include/start_group_replication.inc
110
111 --let $pcu_count = `SELECT COUNT(*) FROM performance_schema.replication_applier_configuration WHERE (CHANNEL_NAME= "group_replication_applier" AND PRIVILEGE_CHECKS_USER = "'root'@'localhost'") OR (CHANNEL_NAME= "group_replication_recovery" AND PRIVILEGE_CHECKS_USER = "'root'@'localhost'")`
112 --let $assert_text= PRIVILEGE_CHECKS_USER has correct value for channel group_replication_applier and group_replication_recovery
113 --let $assert_cond= $pcu_count = 2
114 --source include/assert.inc
115
116 --echo
117 --echo # 7. Cleanup.
118 --echo
119
120 --source include/clean_monitoring_process.inc
121 SET SESSION sql_log_bin = 0;
122 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.");
123 call mtr.add_suppression("Clone removing all user data for provisioning: *");
124 SET SESSION sql_log_bin = 1;
125
126 --source include/group_replication_end.inc