Skip to content

Commit

Permalink
FB8-181: Maintain a whitelist of semi-sync slaves which can ACK trans…
Browse files Browse the repository at this point in the history
…actions (percona#1017)

Summary:
Jira issue: https://jira.percona.com/browse/FB8-181

Reference Patch: facebook/mysql-5.6@ee761fc
Reference Patch: facebook/mysql-5.6@68f34521e82
Reference Patch: facebook/mysql-5.6@dfb038d48d0
Reference Patch: facebook/mysql-5.6@de1e8c7bfe7
Reference Patch: facebook/mysql-5.6@26835a39459

A whitelist of semi-sync slaves can be maintained using a new sys-var
`rpl_semi_sync_master_whitelist`. The value of this variable is a comma
separated list of UUIDs. ACK from any slave which is not in the whitelist will
be ignored. The whitelist is persisted in file
`semi_sync_master_whitelist.info` to survive server restarts.

Porting notice:
You have to use `set @persist.rpl_semi_sync_master_whitelist` to keep
value across server restarts.

Originally Reviewed By: Tema
Pull Request resolved: facebook/mysql-5.6#1017

Reviewed By: yizhang82

Differential Revision: D15285223

Pulled By: yizhang82

fbshipit-source-id: 87fc3ba56d5
  • Loading branch information
abhinav04sharma authored and inikep committed Oct 5, 2020
1 parent 1781b79 commit 57e1e06
Show file tree
Hide file tree
Showing 25 changed files with 804 additions and 16 deletions.
2 changes: 2 additions & 0 deletions mysql-test/include/rpl_connection_slave2.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
let $rpl_connection_name= slave2;
source include/rpl_connection.inc;
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ SET PERSIST_ONLY rpl_semi_sync_master_trace_level = @@GLOBAL.rpl_semi_sync_maste
SET PERSIST_ONLY rpl_semi_sync_master_wait_for_slave_count = @@GLOBAL.rpl_semi_sync_master_wait_for_slave_count;
SET PERSIST_ONLY rpl_semi_sync_master_wait_no_slave = @@GLOBAL.rpl_semi_sync_master_wait_no_slave;
SET PERSIST_ONLY rpl_semi_sync_master_wait_point = @@GLOBAL.rpl_semi_sync_master_wait_point;
SET PERSIST_ONLY rpl_semi_sync_master_whitelist = @@GLOBAL.rpl_semi_sync_master_whitelist;
SET PERSIST_ONLY rpl_semi_sync_slave_enabled = @@GLOBAL.rpl_semi_sync_slave_enabled;
SET PERSIST_ONLY rpl_semi_sync_slave_trace_level = @@GLOBAL.rpl_semi_sync_slave_trace_level;
SET PERSIST_ONLY rpl_send_buffer_size = @@GLOBAL.rpl_send_buffer_size;
Expand Down Expand Up @@ -225,6 +226,7 @@ RESET PERSIST rpl_semi_sync_master_trace_level;
RESET PERSIST rpl_semi_sync_master_wait_for_slave_count;
RESET PERSIST rpl_semi_sync_master_wait_no_slave;
RESET PERSIST rpl_semi_sync_master_wait_point;
RESET PERSIST rpl_semi_sync_master_whitelist;
RESET PERSIST rpl_semi_sync_slave_enabled;
RESET PERSIST rpl_semi_sync_slave_trace_level;
RESET PERSIST rpl_send_buffer_size;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ SET PERSIST rpl_semi_sync_master_trace_level = @@GLOBAL.rpl_semi_sync_master_tra
SET PERSIST rpl_semi_sync_master_wait_for_slave_count = @@GLOBAL.rpl_semi_sync_master_wait_for_slave_count;
SET PERSIST rpl_semi_sync_master_wait_no_slave = @@GLOBAL.rpl_semi_sync_master_wait_no_slave;
SET PERSIST rpl_semi_sync_master_wait_point = @@GLOBAL.rpl_semi_sync_master_wait_point;
SET PERSIST rpl_semi_sync_master_whitelist = @@GLOBAL.rpl_semi_sync_master_whitelist;
SET PERSIST rpl_semi_sync_slave_enabled = @@GLOBAL.rpl_semi_sync_slave_enabled;
SET PERSIST rpl_semi_sync_slave_trace_level = @@GLOBAL.rpl_semi_sync_slave_trace_level;
SET PERSIST rpl_send_buffer_size = @@GLOBAL.rpl_send_buffer_size;
Expand Down Expand Up @@ -254,6 +255,7 @@ RESET PERSIST IF EXISTS rpl_semi_sync_master_trace_level;
RESET PERSIST IF EXISTS rpl_semi_sync_master_wait_for_slave_count;
RESET PERSIST IF EXISTS rpl_semi_sync_master_wait_no_slave;
RESET PERSIST IF EXISTS rpl_semi_sync_master_wait_point;
RESET PERSIST IF EXISTS rpl_semi_sync_master_whitelist;
RESET PERSIST IF EXISTS rpl_semi_sync_slave_enabled;
RESET PERSIST IF EXISTS rpl_semi_sync_slave_trace_level;
RESET PERSIST IF EXISTS rpl_send_buffer_size;
Expand Down
120 changes: 120 additions & 0 deletions mysql-test/suite/rpl/r/rpl_semi_sync_master_whitelist.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
include/rpl_init.inc [topology=1->2,1->3]
Warnings:
Note #### Sending passwords in plain text without SSL/TLS is extremely insecure.
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.
Warnings:
Note #### Sending passwords in plain text without SSL/TLS is extremely insecure.
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.
include/rpl_default_connections.inc
include/rpl_connect.inc [creating slave2]
call mtr.add_suppression("A message intended for a client cannot be sent there as no client-session is attached");
call mtr.add_suppression("Semi-sync master: Received an ACK from an unrecognized slave with UUID");
call mtr.add_suppression("Semi-sync master failed on net_flush.. before waiting for slave reply");
call mtr.add_suppression("Run function 'transmit_start' in plugin 'rpl_semi_sync_master' failed");
call mtr.add_suppression("Failed to register slave to semi-sync ACK receiver thread.*");
call mtr.add_suppression("Slave I/O for channel '': Master command COM_REGISTER_SLAVE failed: failed registering on master");
call mtr.add_suppression("Slave I/O for channel '': SET @master_heartbeat_period");
call mtr.add_suppression("Read semi-sync reply magic number error");
[connection master]
create table t1(a int) engine=innodb;
insert into t1 values(0);
include/sync_slave_sql_with_master.inc
[connection master]
include/sync_slave_sql_with_master.inc
[connection slave1]
include/assert.inc [The t1 table should have 1 row]
[connection slave2]
include/assert.inc [The t1 table should have 1 row]
[connection slave1]
[connection slave2]
[connection master]
set @@persist.rpl_semi_sync_master_whitelist = "slave1_uuid,slave2_uuid";
[connection master]
insert into t1 values(1);
insert into t1 values(2);
include/assert.inc [The t1 table should have 3 rows]
include/sync_slave_sql_with_master.inc
[connection master]
include/sync_slave_sql_with_master.inc
[connection slave1]
include/assert.inc [The t1 table should have 3 rows]
[connection slave2]
include/assert.inc [The t1 table should have 3 rows]
[connection slave1]
include/stop_slave.inc
[connection master]
insert into t1 values(3);
insert into t1 values(4);
include/assert.inc [The t1 table should have 5 rows]
include/sync_slave_sql_with_master.inc
include/assert.inc [The t1 table should have 5 rows]
[connection slave1]
include/start_slave.inc
[connection master]
include/sync_slave_sql_with_master.inc
include/assert.inc [The t1 table should have 5 rows]
include/rpl_stop_slaves.inc
[connection master]
include/rpl_restart_server.inc [server_number=1]
include/rpl_start_slaves.inc
[connection master]
select @@global.rpl_semi_sync_master_whitelist;
@@global.rpl_semi_sync_master_whitelist
slave1_uuid,slave2_uuid
[connection slave1]
include/stop_slave.inc
[connection slave2]
include/stop_slave.inc
[connection master1]
insert into t1 values(5);
[connection master]
include/assert.inc [The t1 table should have 5 rows]
[connection slave1]
include/start_slave.inc
[connection slave2]
include/start_slave.inc
[connection master1]
include/assert.inc [The t1 table should have 6 rows]
[connection master]
include/sync_slave_sql_with_master.inc
include/assert.inc [The t1 table should have 6 rows]
[connection master]
include/sync_slave_sql_with_master.inc
include/assert.inc [The t1 table should have 6 rows]
[connection master]
set @@global.rpl_semi_sync_master_whitelist='-slave2_uuid';
[connection slave1]
include/stop_slave.inc
[connection master1]
insert into t1 values(6);
[connection master]
[connection slave1]
include/start_slave.inc
[connection master1]
set @@global.rpl_semi_sync_master_whitelist='+slave2_uuid';
include/assert.inc [The t1 table should have 7 rows]
[connection master]
include/sync_slave_sql_with_master.inc
include/assert.inc [The t1 table should have 7 rows]
[connection master]
include/sync_slave_sql_with_master.inc
include/assert.inc [The t1 table should have 7 rows]
[connection master]
set @@global.rpl_semi_sync_master_whitelist='';
[connection master1]
insert into t1 values(7);
[connection master]
set @@global.rpl_semi_sync_master_whitelist = "slave1_uuid,slave2_uuid";
[connection master1]
include/assert.inc [The t1 table should have 8 rows]
[connection master]
include/sync_slave_sql_with_master.inc
include/assert.inc [The t1 table should have 8 rows]
[connection master]
include/sync_slave_sql_with_master.inc
include/assert.inc [The t1 table should have 8 rows]
[connection master]
drop table t1;
set @@global.rpl_semi_sync_master_whitelist = ANY;
reset persist rpl_semi_sync_master_whitelist;
include/rpl_end.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
$SEMISYNC_MASTER_PLUGIN_OPT --plugin-load=rpl_semi_sync_master=$SEMISYNC_MASTER_PLUGIN;rpl_semi_sync_slave=$SEMISYNC_SLAVE_PLUGIN
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
$SEMISYNC_SLAVE_PLUGIN_OPT $SEMISYNC_SLAVE_PLUGIN_LOAD
15 changes: 15 additions & 0 deletions mysql-test/suite/rpl/t/rpl_semi_sync_master_whitelist.cnf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
!include ../my.cnf

[mysqld.1]
rpl_semi_sync_master_enabled=1
rpl_semi_sync_master_timeout=86400000 # 1 day

[mysqld.2]
rpl_semi_sync_slave_enabled=1

[mysqld.3]
master-retry-count=10
rpl_semi_sync_slave_enabled=1

[ENV]
SERVER_MYPORT_3= @mysqld.3.port
Loading

0 comments on commit 57e1e06

Please sign in to comment.