Skip to content

Commit acbf1d1

Browse files
Hemant DangiHery Ramilison
authored andcommitted
Bug#26314756: ASYNCHRONOUS_CHANNELS_STATE_OBSERVER INITIALIZATION MISSING FROM DELAYED GR
Issue: ====== In case of delayed server start GR plugin starts from Delayed_initialization_thread::initialization_thread_handler class and not from plugin_group_replication_start(). asynchronous_channels_state_observer observers which keep track of all replication channel starts, stop, .. won't get start in this case as it is not getting initialized. As asynchronous replication channel cannot be started on secondary, while group replication is running on single primary-mode, this missing initialization of asynchronous_channels_state_observer will allow secondaries to start asynchronous replication channel and get data through asynchronous replication. Solution: ========= Add missing initialize_asynchronous_channels_observer() function in Delayed_initialization_thread::initialization_thread_handler(). (cherry picked from commit 160aef6fc359e093ddbaaa346fa1570e8357e4ac)
1 parent c4f02fd commit acbf1d1

File tree

7 files changed

+369
-17
lines changed

7 files changed

+369
-17
lines changed

rapid/plugin/group_replication/include/plugin.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ bool get_allow_local_disjoint_gtids_join();
102102
ulong get_transaction_size_limit();
103103
void initialize_asynchronous_channels_observer();
104104
void terminate_asynchronous_channels_observer();
105+
bool check_async_channel_running_on_secondary();
105106

106107
//Plugin public methods
107108
int plugin_group_replication_init(MYSQL_PLUGIN plugin_info);

rapid/plugin/group_replication/src/delayed_plugin_initialization.cc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,16 @@ int Delayed_initialization_thread::initialization_thread_handler()
182182
server_version)))
183183
goto err; /* purecov: inspected */
184184

185+
if (check_async_channel_running_on_secondary())
186+
{
187+
error= 1;
188+
log_message(MY_ERROR_LEVEL, "Can't start group replication on secondary"
189+
" member with single primary-mode while"
190+
" asynchronous replication channels are"
191+
" running.");
192+
goto err; /* purecov: inspected */
193+
}
194+
185195
configure_compatibility_manager();
186196

187197
if ((error= initialize_recovery_module()))
@@ -193,6 +203,7 @@ int Delayed_initialization_thread::initialization_thread_handler()
193203
goto err;
194204
}
195205

206+
initialize_asynchronous_channels_observer();
196207
initialize_group_partition_handler();
197208
blocked_transaction_handler= new Blocked_transaction_handler();
198209

rapid/plugin/group_replication/src/plugin.cc

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -405,24 +405,14 @@ int plugin_group_replication_start()
405405
server_version)))
406406
goto err; /* purecov: inspected */
407407

408-
/* To stop group replication to start on secondary member with single primary-
409-
mode, when any async channels are running, we verify whether member is not
410-
bootstrapping. As only when the member is bootstrapping, it can be the
411-
primary leader on a single primary member context.
412-
413-
*/
414-
if (single_primary_mode_var && !bootstrap_group_var)
408+
if (check_async_channel_running_on_secondary())
415409
{
416-
if (is_any_slave_channel_running(
417-
CHANNEL_RECEIVER_THREAD | CHANNEL_APPLIER_THREAD))
418-
{
419-
error= 1;
420-
log_message(MY_ERROR_LEVEL, "Can't start group replication on secondary"
421-
" member with single primary-mode while"
422-
" asynchronous replication channels are"
423-
" running.");
424-
goto err; /* purecov: inspected */
425-
}
410+
error= 1;
411+
log_message(MY_ERROR_LEVEL, "Can't start group replication on secondary"
412+
" member with single primary-mode while"
413+
" asynchronous replication channels are"
414+
" running.");
415+
goto err; /* purecov: inspected */
426416
}
427417

428418
configure_compatibility_manager();
@@ -1304,6 +1294,25 @@ int start_group_communication()
13041294
DBUG_RETURN(0);
13051295
}
13061296

1297+
bool check_async_channel_running_on_secondary()
1298+
{
1299+
/* To stop group replication to start on secondary member with single primary-
1300+
mode, when any async channels are running, we verify whether member is not
1301+
bootstrapping. As only when the member is bootstrapping, it can be the
1302+
primary leader on a single primary member context.
1303+
*/
1304+
if (single_primary_mode_var && !bootstrap_group_var)
1305+
{
1306+
if (is_any_slave_channel_running(
1307+
CHANNEL_RECEIVER_THREAD | CHANNEL_APPLIER_THREAD))
1308+
{
1309+
return true;
1310+
}
1311+
}
1312+
1313+
return false;
1314+
}
1315+
13071316
void initialize_asynchronous_channels_observer()
13081317
{
13091318
if (single_primary_mode_var)
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
include/group_replication.inc [rpl_server_count=3]
2+
Warnings:
3+
Note #### Sending passwords in plain text without SSL/TLS is extremely insecure.
4+
Note #### Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information.
5+
[connection server1]
6+
7+
# 1. Restart server1(primary) with group replication start on boot
8+
[connection server1]
9+
# restart:--group-replication-start-on-boot=1 --group-replication-group-name=GROUP_REPLICATION_GROUP_NAME --group_replication_local_address=GROUP_REPLICATION_LOCAL_ADDRESS --group_replication_group_seeds=GROUP_REPLICATION_GROUP_SEEDS --group_replication_bootstrap_group=1 --group_replication_single_primary_mode=1 --group_replication_enforce_update_everywhere_checks=0
10+
include/rpl_reconnect.inc
11+
12+
# 2. Wait for GR to come ONLINE
13+
include/gr_wait_for_member_state.inc
14+
15+
# 3. Create and start new channel ch3_1: server1(slave), server3(master)
16+
[connection server1]
17+
CHANGE MASTER TO MASTER_HOST='localhost', MASTER_USER='root', MASTER_PORT=SERVER_3_PORT for channel 'ch3_1';
18+
Warnings:
19+
Note 1759 Sending passwords in plain text without SSL/TLS is extremely insecure.
20+
Note 1760 Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information.
21+
include/start_slave.inc
22+
23+
# 4. Verify channel ch3_1 IO and SQL THREADS are ON
24+
include/assert.inc [Verify channel ch3_1 IO_THREAD is ON]
25+
include/assert.inc [Verify channel ch3_1 SQL_THREAD is ON]
26+
[connection server2]
27+
28+
# 5. Restart server2(secondary) with group replication start on boot
29+
# restart:--group-replication-start-on-boot=1 --group-replication-group-name=GROUP_REPLICATION_GROUP_NAME --group_replication_local_address=GROUP_REPLICATION_LOCAL_ADDRESS --group_replication_group_seeds=GROUP_REPLICATION_GROUP_SEEDS --group_replication_single_primary_mode=1 --group_replication_enforce_update_everywhere_checks=0
30+
include/rpl_reconnect.inc
31+
32+
# 6. Wait for GR to come ONLINE
33+
include/gr_wait_for_member_state.inc
34+
35+
# 7. Create new channel ch3_2: server2(slave), server3(master)
36+
CHANGE MASTER TO MASTER_HOST='localhost', MASTER_USER='root', MASTER_PORT=SERVER_3_PORT for channel 'ch3_2';
37+
Warnings:
38+
Note 1759 Sending passwords in plain text without SSL/TLS is extremely insecure.
39+
Note 1760 Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information.
40+
41+
# 8. start slave and verify for error ER_SLAVE_FATAL_ERROR
42+
START SLAVE FOR CHANNEL 'ch3_2';
43+
include/wait_for_slave_io_error.inc [errno=1593]
44+
include/wait_for_slave_sql_error.inc [errno=1593]
45+
46+
# 9. start slave io and verify for error ER_SLAVE_FATAL_ERROR
47+
START SLAVE IO_THREAD FOR CHANNEL 'ch3_2';
48+
include/wait_for_slave_io_error.inc [errno=1593]
49+
50+
# 10. start slave sql and verify for error ER_SLAVE_FATAL_ERROR
51+
START SLAVE SQL_THREAD FOR CHANNEL 'ch3_2';
52+
include/wait_for_slave_sql_error.inc [errno=1593]
53+
54+
# 11. Verify occurrence of error message
55+
Occurrences of 'Can't start slave IO THREAD when group replication is running with single primary-mode on a secondary member' in the input file: 2
56+
Occurrences of 'Can't start slave SQL THREAD when group replication is running with single primary-mode on a secondary member' in the input file: 2
57+
58+
# 12. Verify channel ch3_2 IO & SQL THREAD is OFF
59+
include/assert.inc [Verify channel ch3_2 IO_THREAD is OFF]
60+
include/assert.inc [Verify channel ch3_2 SQL_THREAD is OFF]
61+
62+
# 13. Stop group replication on server2
63+
include/stop_group_replication.inc
64+
include/start_slave.inc
65+
66+
# 14. Restart server2(secondary) with group replication start on boot
67+
# restart:--group-replication-start-on-boot=1 --group-replication-group-name=GROUP_REPLICATION_GROUP_NAME --group_replication_local_address=GROUP_REPLICATION_LOCAL_ADDRESS --group_replication_group_seeds=GROUP_REPLICATION_GROUP_SEEDS --group_replication_single_primary_mode=1 --group_replication_enforce_update_everywhere_checks=0 --skip-slave-start=0
68+
include/rpl_reconnect.inc
69+
70+
# 15. Wait for GR to be in OFFLINE status
71+
include/gr_wait_for_member_state.inc
72+
73+
# 16. Wait for channel ch3_2 to start and verify IO and SQL THREADS are ON
74+
include/wait_for_slave_to_start.inc
75+
include/assert.inc [Verify channel ch3_2 IO_THREAD is ON]
76+
include/assert.inc [Verify channel ch3_2 SQL_THREAD is ON]
77+
78+
# 17. Verify occurrence of error message
79+
Occurrences of 'Can't start group replication on secondary member with single primary-mode while asynchronous replication channels are running' in the input file: 1
80+
81+
# 18. Cleanup
82+
[connection server1]
83+
include/stop_slave.inc
84+
RESET SLAVE ALL FOR CHANNEL 'ch3_1';
85+
[connection server2]
86+
include/stop_slave.inc
87+
RESET SLAVE ALL FOR CHANNEL 'ch3_2';
88+
include/stop_slave.inc
89+
include/group_replication_end.inc
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
--no-console --log_error=$MYSQLTEST_VARDIR/tmp/gr_single_primary_async_gr_start_on_boot.err
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
!include ../my.cnf
2+
3+
[mysqld.1]
4+
5+
[mysqld.2]
6+
7+
[mysqld.3]
8+
9+
[ENV]
10+
SERVER_MYPORT_3= @mysqld.3.port
11+
SERVER_MYSOCK_3= @mysqld.3.socket

0 commit comments

Comments
 (0)