Debian Codegraph @

mysql-test/suite/rpl_nogtid/t/rpl_semi_sync_uninstall_plugin.test

raw
1 # ==== Purpose ====
2 #
3 # Verify that UNINSTALL PLUGIN is blocked for semisync plugins, when
4 # the plugins are active.
5 #
6 # ==== Requirements ====
7 #
8 # R1. Installation of source plugins should be disallowed if there are
9 # running dump threads having semi-sync replicas.
10 #
11 # R2. Installation of replica plugins should be disallowed if there are
12 # running receiver threads where semi-sync is enabled.
13 #
14 # R3. The above should hold both for old-named plugins and for new-named
15 # plugins.
16 #
17 # ==== References ====
18 #
19 # BUG#17638477 UNINSTALL AND INSTALL SEMI-SYNC PLUGIN CAUSES SLAVES TO BREAK
20 # Uninstallation was not blocked before this bugfix.
21 #
22 # BUG#33270401: Uninstall not blocked for active old-named semi-sync replication plugins
23 # Uninstallation was not blocked on old-named plugins before this bugfix.
24
25 --source include/have_semisync_plugin.inc
26 --source include/have_binlog_format_statement.inc
27 --source include/master-slave.inc
28
29 --let $status = _status
30 --let $clients = _clients
31 --let $enabled = _enabled
32
33 --let $old_names = 0
34 while ($old_names < 2) {
35 if ($old_names == 0) {
36 --let $source = source
37 --let $replica = replica
38 --let $source_plugin = $SEMISYNC_SOURCE_PLUGIN
39 --let $replica_plugin = $SEMISYNC_REPLICA_PLUGIN
40 }
41 if ($old_names == 1) {
42 --let $source = master
43 --let $replica = slave
44 --let $source_plugin = $SEMISYNC_MASTER_PLUGIN
45 --let $replica_plugin = $SEMISYNC_SLAVE_PLUGIN
46 }
47 --let $use_old_semisync_plugin_names = $old_names
48
49 --echo ==== Step $old_names: Using $source/$replica terminology ====
50
51 --source include/rpl_connection_master.inc
52
53 #############################################################################
54 --echo # Case 1: Uninstallation of semi sync plugins should be allowed when it is
55 --echo # not in use i.e., when asynchronous replication is active.
56
57 # Step 1.1: Install semi sync master plugin on master
58 --replace_result $source_plugin SEMISYNC_SOURCE_PLUGIN
59 eval INSTALL PLUGIN rpl_semi_sync_$source SONAME '$source_plugin';
60
61 # Step 1.2: Install semi sync slave plugin on slave
62 --connection slave
63 --replace_result $replica_plugin SEMISYNC_REPLICA_PLUGIN
64 eval INSTALL PLUGIN rpl_semi_sync_$replica SONAME '$replica_plugin';
65
66 # Step 1.3: Uninstallation of semisync plugin on master and slave should be
67 # allowed at this state as there is no semi sync replication enabled between
68 # master and slave.
69 eval UNINSTALL PLUGIN rpl_semi_sync_$replica;
70 --connection master
71 eval UNINSTALL PLUGIN rpl_semi_sync_$source;
72
73 # Step 1.4: Check that replication is working fine at the end of the test case.
74 CREATE TABLE t1(i int);
75 INSERT INTO t1 values (1);
76 DROP TABLE t1;
77 --sync_slave_with_master
78
79 #############################################################################
80 --echo # Case 2: Uninstallation of semi sync plugins should be disallowed
81 --echo # when it is in use i.e., when semi sync replication is active
82
83 # Step 2.1: Install and enable semi sync replication between master and slave
84 --source include/install_semisync.inc
85
86 # Step 2.2: Check that rpl_semi_sync_replica uninstallation on Slave is not
87 # possible at this state
88 --connection slave
89 eval call mtr.add_suppression("Plugin 'rpl_semi_sync_$replica' cannot be uninstalled now");
90 --error ER_PLUGIN_CANNOT_BE_UNINSTALLED
91 eval UNINSTALL PLUGIN rpl_semi_sync_$replica;
92
93 # Step 2.3: Check that rpl_semi_sync_source uninstallation on Master is not
94 # possible at this state
95 --connection master
96 eval call mtr.add_suppression("Plugin 'rpl_semi_sync_$source' cannot be uninstalled now");
97 --error ER_PLUGIN_CANNOT_BE_UNINSTALLED
98 eval UNINSTALL PLUGIN rpl_semi_sync_$source;
99
100 # Step 2.4: Check that replication is working fine at the end of the test case.
101 CREATE TABLE t1(i int);
102 INSERT INTO t1 values (2);
103 DROP TABLE t1;
104 --sync_slave_with_master
105
106 # Step 2.5: Make sure rpl_semi_sync_source_status on Master and
107 # rpl_semi_sync_replica_staus on Slave are ON
108 --let $slave_status=[show status like "Rpl_semi_sync_$replica$status", Value, 1]
109 --let assert_cond= "$slave_status" = "ON"
110 --let assert_text= semi sync slave status should be ON.
111 --source include/assert.inc
112
113 --connection master
114 --let $master_status=[show status like "Rpl_semi_sync_$source$status", Value, 1]
115 --let assert_cond= "$master_status" = "ON"
116 --let assert_text= semi sync master status should be ON.
117 --source include/assert.inc
118
119 --let $master_clients=[show status like "Rpl_semi_sync_$source$clients", Value, 1]
120 --let assert_cond= $master_clients = 1
121 --let assert_text= semi sync master clients should be 1.
122 --source include/assert.inc
123
124 #############################################################################
125 --echo # Case 3: Uninstallation of semi sync plugin should be disallowed when there
126 --echo # are semi sync slaves even though rpl_semi_sync_source_enabled= OFF;.
127
128 # Step 3.1: Disable semi sync on master
129 --connection master
130 eval SET GLOBAL rpl_semi_sync_$source$enabled = OFF;
131
132 # Step 3.2: Check that still Rpl_semi_sync_source_clients is 1
133 --let $master_clients=[show status like "Rpl_semi_sync_$source$clients", Value, 1]
134 --let assert_cond= $master_clients = 1
135 --let assert_text= semi sync master clients should be 1.
136 --source include/assert.inc
137
138 # Step 3.3: Since Rpl_semi_sync_source_clients is 1, uninstallation of
139 # rpl_semi_sync_source should be disallowed.
140 --error ER_PLUGIN_CANNOT_BE_UNINSTALLED
141 eval UNINSTALL PLUGIN rpl_semi_sync_$source;
142
143 #############################################################################
144 --echo # Case 4: Uninstallation of semi sync plugin should be allowed when it is not
145 --echo # in use. Same as Case 1 but this case is to check the case after enabling and
146 --echo # disabling semi sync replication.
147
148 # Step 4.1: Stop IO thread on slave.
149 --connection slave
150 --source include/stop_slave.inc
151
152 # Step 4.2: Disable semi sync on slave.
153 eval SET GLOBAL rpl_semi_sync_$replica$enabled = OFF;
154
155 # Step 4.3: Start IO thread on slave.
156 --source include/start_slave.inc
157
158 # Step 4.4: Uninstall semi sync plugin, it should be successful now.
159 eval UNINSTALL PLUGIN rpl_semi_sync_$replica;
160
161 # Step 4.5: On Master, wait until semi sync slaves is '0'.
162 --connection master
163 --let $status_var= Rpl_semi_sync_$source$clients
164 --let $status_var_value= 0
165 --source include/wait_for_status_var.inc
166
167 # Step 4.6: So uninstalling semi sync plugin should be allowed
168 eval UNINSTALL PLUGIN rpl_semi_sync_$source;
169
170 # Step 4.7: Check that replication is working fine at the end of the test case
171 CREATE TABLE t1(i int);
172 INSERT INTO t1 values (3);
173 DROP TABLE t1;
174 --sync_slave_with_master
175
176 --inc $old_names
177 }
178
179 # Cleanup
180 source include/rpl_end.inc;