Skip to content

Commit 846ced2

Browse files
author
Hemant Dangi
committed
Bug#26263155: GR OVERRIDES AUTO_INC_INCREMENT=1 AND AUTO_INC_OFFSET=1 ON SINGLE-PRIMARY MODE
Issue: ====== The Group Replication plugin set auto_increment_increment and auto_increment_offset values to server_id and 7 respectively by default to avoid generating duplicate auto-incrementing values. But in single primary mode there are writes from only one server(primary), so there is no need to generate different auto-increment values. Solution: ========= The Group Replication plugin should not set auto_increment_increment and auto_increment_offset variables when single primary mode is active.
1 parent 0a6ee74 commit 846ced2

File tree

7 files changed

+170
-15
lines changed

7 files changed

+170
-15
lines changed

rapid/plugin/group_replication/include/plugin.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ int configure_compatibility_manager();
9191
int terminate_applier_module();
9292
int initialize_recovery_module();
9393
void initialize_group_partition_handler();
94+
void set_auto_increment_handler();
9495
int terminate_recovery_module();
9596
int configure_group_communication(st_server_ssl_variables *ssl_variables);
9697
int start_group_communication();

rapid/plugin/group_replication/src/auto_increment.cc

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
1+
/* Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
22
33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License as published by
@@ -39,7 +39,8 @@ reset_auto_increment_variables()
3939
group_replication_auto_increment_increment and
4040
group_replication_auto_increment_offset
4141
*/
42-
if (group_replication_auto_increment == current_server_increment &&
42+
if (local_member_info != NULL && !local_member_info->in_primary_mode() &&
43+
group_replication_auto_increment == current_server_increment &&
4344
group_replication_auto_offset == current_server_offset)
4445
{
4546
/* set to default values i.e. 1 */
@@ -64,7 +65,8 @@ set_auto_increment_variables(ulong increment, ulong offset)
6465
ulong current_server_increment= get_auto_increment_increment();
6566
ulong current_server_offset= get_auto_increment_offset();
6667

67-
if (current_server_increment == 1 &&
68+
if (local_member_info != NULL && !local_member_info->in_primary_mode() &&
69+
current_server_increment == 1 &&
6870
current_server_offset == 1)
6971
{
7072
/* set server auto_increment variables */

rapid/plugin/group_replication/src/delayed_plugin_initialization.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@ int Delayed_initialization_thread::initialization_thread_handler()
231231

232232
initialize_asynchronous_channels_observer();
233233
initialize_group_partition_handler();
234+
set_auto_increment_handler();
234235

235236
if ((error= start_group_communication()))
236237
{

rapid/plugin/group_replication/src/gcs_event_handlers.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -915,7 +915,8 @@ void Plugin_gcs_events_handler::handle_joining_members(const Gcs_view& new_view,
915915
*/
916916
ulong auto_increment_increment= get_auto_increment_increment();
917917

918-
if (new_view.get_members().size() > auto_increment_increment)
918+
if (!local_member_info->in_primary_mode() &&
919+
new_view.get_members().size() > auto_increment_increment)
919920
{
920921
log_message(MY_ERROR_LEVEL,
921922
"Group contains %lu members which is greater than"

rapid/plugin/group_replication/src/plugin.cc

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,7 @@ int plugin_group_replication_start()
531531

532532
initialize_asynchronous_channels_observer();
533533
initialize_group_partition_handler();
534+
set_auto_increment_handler();
534535

535536
if ((error= start_group_communication()))
536537
{
@@ -742,10 +743,7 @@ int leave_group()
742743
// Finalize GCS.
743744
gcs_module->finalize();
744745

745-
if (auto_increment_handler != NULL)
746-
{
747-
auto_increment_handler->reset_auto_increment_variables();
748-
}
746+
auto_increment_handler->reset_auto_increment_variables();
749747

750748
// Destroy handlers and notifiers
751749
delete events_handler;
@@ -1189,6 +1187,13 @@ void initialize_group_partition_handler()
11891187
timeout_on_unreachable_var);
11901188
}
11911189

1190+
void set_auto_increment_handler()
1191+
{
1192+
auto_increment_handler->
1193+
set_auto_increment_variables(auto_increment_increment_var,
1194+
get_server_id());
1195+
}
1196+
11921197
int terminate_applier_module()
11931198
{
11941199

@@ -1361,13 +1366,6 @@ int start_group_communication()
13611366
{
13621367
DBUG_ENTER("start_group_communication");
13631368

1364-
if (auto_increment_handler != NULL)
1365-
{
1366-
auto_increment_handler->
1367-
set_auto_increment_variables(auto_increment_increment_var,
1368-
get_server_id());
1369-
}
1370-
13711369
view_change_notifier= new Plugin_gcs_view_modification_notifier();
13721370
events_handler= new Plugin_gcs_events_handler(applier_module,
13731371
recovery_module,
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
include/group_replication.inc
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. Start Group Replication on server1
8+
[connection server1]
9+
include/start_and_bootstrap_group_replication.inc
10+
#
11+
# 2. Save initial value of GROUP_REPLICATION_AUTO_INCREMENT_INCREMENT for server2
12+
[connection server2]
13+
# 3. Verify default values of group_replication_auto_increment_increment,
14+
# auto_increment_increment and auto_increment_offset.
15+
include/assert.inc [The default value of group_replication_auto_increment_increment should be 7]
16+
include/assert.inc [The default value of auto_increment_increment should be 1]
17+
include/assert.inc [The default value of auto_increment_offset should be 1]
18+
# 4. Start group replication on server2.
19+
include/start_group_replication.inc
20+
# 5. Verify the values of group_replication_auto_increment_increment,
21+
# auto_increment_increment and auto_increment_offset after starting GR.
22+
include/assert.inc [The value of group_replication_auto_increment_increment is still 7]
23+
include/assert.inc [The value of auto_increment_increment is set to 1]
24+
include/assert.inc [The value of auto_increment_offset is set to 1]
25+
# 6. Set group_replication_auto_increment_increment
26+
# and restart group replication.
27+
include/stop_group_replication.inc
28+
SET GLOBAL GROUP_REPLICATION_AUTO_INCREMENT_INCREMENT= 3;
29+
include/start_group_replication.inc
30+
# 7. Verify the effects of group_replication_auto_increment_increment
31+
# on auto_increment_increment on starting GR.
32+
include/assert.inc [The value of group_replication_auto_increment_increment is still 3]
33+
include/assert.inc [The value of auto_increment_increment is set to 1]
34+
# 8. Verify that auto_increment_offset is still is set to default
35+
include/assert.inc [The value of auto_increment_offset is set to 1]
36+
# 9. Cleanup
37+
include/stop_group_replication.inc
38+
SET GLOBAL GROUP_REPLICATION_AUTO_INCREMENT_INCREMENT= 7;
39+
include/group_replication_end.inc
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
################################################################################
2+
# This test verifies that auto_increment_increment and auto_increment_offset
3+
# are set to its default value of 1, when configure in single primary mode and
4+
# any change to group_replication_auto_increment_increment doesn't affect its
5+
# value.
6+
#
7+
# Test:
8+
# 0. The test requires two servers: M1 and M2.
9+
# 1. Start Group Replication on server1
10+
# 2. Save initial value of GROUP_REPLICATION_AUTO_INCREMENT_INCREMENT for server2
11+
# 3. Verify default values of group_replication_auto_increment_increment,
12+
# auto_increment_increment and auto_increment_offset.
13+
# 4. Start group replication on server2.
14+
# 5. Verify the values of group_replication_auto_increment_increment,
15+
# auto_increment_increment and auto_increment_offset after starting GR.
16+
# 6. Set group_replication_auto_increment_increment
17+
# and restart group replication.
18+
# 7. Verify the effects of group_replication_auto_increment_increment
19+
# on auto_increment_increment on starting GR.
20+
# 8. Verify that auto_increment_offset is still is set to default
21+
# 9. Clean up.
22+
################################################################################
23+
--source include/big_test.inc
24+
--source ../inc/have_group_replication_plugin.inc
25+
--let $rpl_skip_group_replication_start= 1
26+
--let $rpl_group_replication_single_primary_mode=1
27+
--source ../inc/group_replication.inc
28+
29+
30+
--echo #
31+
--echo # 1. Start Group Replication on server1
32+
--let $rpl_connection_name= server1
33+
--source include/rpl_connection.inc
34+
--source ../inc/start_and_bootstrap_group_replication.inc
35+
36+
37+
--echo #
38+
--echo # 2. Save initial value of GROUP_REPLICATION_AUTO_INCREMENT_INCREMENT for server2
39+
--let $rpl_connection_name= server2
40+
--source include/rpl_connection.inc
41+
--let $_init_auto_increment= `SELECT @@GLOBAL.GROUP_REPLICATION_AUTO_INCREMENT_INCREMENT`
42+
43+
44+
--echo # 3. Verify default values of group_replication_auto_increment_increment,
45+
--echo # auto_increment_increment and auto_increment_offset.
46+
47+
--let $assert_text= The default value of group_replication_auto_increment_increment should be 7
48+
--let $assert_cond= [SELECT @@GLOBAL.group_replication_auto_increment_increment] = 7
49+
--source include/assert.inc
50+
51+
--let $assert_text= The default value of auto_increment_increment should be 1
52+
--let $assert_cond= [SELECT @@GLOBAL.auto_increment_increment] = 1
53+
--source include/assert.inc
54+
55+
--let $assert_text= The default value of auto_increment_offset should be 1
56+
--let $assert_cond= [SELECT @@GLOBAL.auto_increment_offset] = 1
57+
--source include/assert.inc
58+
59+
60+
--echo # 4. Start group replication on server2.
61+
--source include/start_group_replication.inc
62+
63+
64+
--echo # 5. Verify the values of group_replication_auto_increment_increment,
65+
--echo # auto_increment_increment and auto_increment_offset after starting GR.
66+
67+
--let $assert_text= The value of group_replication_auto_increment_increment is still 7
68+
--let $assert_cond= [SELECT @@GLOBAL.group_replication_auto_increment_increment] = 7
69+
--source include/assert.inc
70+
71+
--let $assert_text= The value of auto_increment_increment is set to 1
72+
--let $assert_cond= [SELECT @@GLOBAL.auto_increment_increment] = 1
73+
--source include/assert.inc
74+
75+
--let $assert_text= The value of auto_increment_offset is set to 1
76+
--let $assert_cond= [SELECT @@GLOBAL.auto_increment_offset] = 1
77+
--source include/assert.inc
78+
79+
80+
--echo # 6. Set group_replication_auto_increment_increment
81+
--echo # and restart group replication.
82+
83+
--source include/stop_group_replication.inc
84+
85+
SET GLOBAL GROUP_REPLICATION_AUTO_INCREMENT_INCREMENT= 3;
86+
87+
--source include/start_group_replication.inc
88+
89+
90+
--echo # 7. Verify the effects of group_replication_auto_increment_increment
91+
--echo # on auto_increment_increment on starting GR.
92+
93+
--let $assert_text= The value of group_replication_auto_increment_increment is still 3
94+
--let $assert_cond= [SELECT @@GLOBAL.group_replication_auto_increment_increment] = 3
95+
--source include/assert.inc
96+
97+
--let $assert_text= The value of auto_increment_increment is set to 1
98+
--let $assert_cond= [SELECT @@GLOBAL.auto_increment_increment] = 1
99+
--source include/assert.inc
100+
101+
102+
--echo # 8. Verify that auto_increment_offset is still is set to default
103+
--let $assert_text= The value of auto_increment_offset is set to 1
104+
--let $assert_cond= [SELECT @@GLOBAL.auto_increment_offset] = 1
105+
--source include/assert.inc
106+
107+
108+
--echo # 9. Cleanup
109+
--source include/stop_group_replication.inc
110+
--eval SET GLOBAL GROUP_REPLICATION_AUTO_INCREMENT_INCREMENT= $_init_auto_increment
111+
112+
113+
--source ../inc/group_replication_end.inc

0 commit comments

Comments
 (0)