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 (facebook#1017) (facebook#1017)

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

Reference Patch: facebook@ee761fc
Reference Patch: facebook@68f34521e82
Reference Patch: facebook@dfb038d48d0
Reference Patch: facebook@de1e8c7bfe7
Reference Patch: facebook@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#1017

Differential Revision: D15285223

Pulled By: yizhang82

--------------------------------------------------------------------------

Fix rpl.rpl_semi_sync_master_whitelist test in valgrind

Summary:
Increase the retry counts for valgrind runs.

Also increase the shutdown_timeout for valgrind runs to give more time
for shutdown to complete.

Reviewed By: Pushapgl

Differential Revision: D33359920
  • Loading branch information
inikep committed May 10, 2024
1 parent a09e0ff commit 9a3a9d6
Show file tree
Hide file tree
Showing 24 changed files with 802 additions and 20 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;
1 change: 1 addition & 0 deletions mysql-test/mysql-test-run.pl
Original file line number Diff line number Diff line change
Expand Up @@ -2471,6 +2471,7 @@ sub command_line_setup {
$opt_suite_timeout *= 6;
$opt_start_timeout *= 10;
$opt_debug_sync_timeout *= 10;
$opt_shutdown_timeout *= 20;
} elsif ($opt_valgrind_mysqld) {
mtr_report("Turning on valgrind for mysqld(s) only");
$opt_valgrind = 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ SET PERSIST_ONLY rpl_semi_sync_source_trace_level = @@GLOBAL.rpl_semi_sync_sourc
SET PERSIST_ONLY rpl_semi_sync_source_wait_for_replica_count = @@GLOBAL.rpl_semi_sync_source_wait_for_replica_count;
SET PERSIST_ONLY rpl_semi_sync_source_wait_no_replica = @@GLOBAL.rpl_semi_sync_source_wait_no_replica;
SET PERSIST_ONLY rpl_semi_sync_source_wait_point = @@GLOBAL.rpl_semi_sync_source_wait_point;
SET PERSIST_ONLY rpl_semi_sync_source_whitelist = @@GLOBAL.rpl_semi_sync_source_whitelist;
SET PERSIST_ONLY rpl_send_buffer_size = @@GLOBAL.rpl_send_buffer_size;
SET PERSIST_ONLY rpl_stop_replica_timeout = @@GLOBAL.rpl_stop_replica_timeout;
SET PERSIST_ONLY rpl_stop_slave_timeout = @@GLOBAL.rpl_stop_slave_timeout;
Expand Down Expand Up @@ -401,6 +402,7 @@ RESET PERSIST rpl_semi_sync_source_trace_level;
RESET PERSIST rpl_semi_sync_source_wait_for_replica_count;
RESET PERSIST rpl_semi_sync_source_wait_no_replica;
RESET PERSIST rpl_semi_sync_source_wait_point;
RESET PERSIST rpl_semi_sync_source_whitelist;
RESET PERSIST rpl_send_buffer_size;
RESET PERSIST rpl_stop_replica_timeout;
RESET PERSIST session_track_gtids;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ SET PERSIST rpl_semi_sync_source_trace_level = @@GLOBAL.rpl_semi_sync_source_tra
SET PERSIST rpl_semi_sync_source_wait_for_replica_count = @@GLOBAL.rpl_semi_sync_source_wait_for_replica_count;
SET PERSIST rpl_semi_sync_source_wait_no_replica = @@GLOBAL.rpl_semi_sync_source_wait_no_replica;
SET PERSIST rpl_semi_sync_source_wait_point = @@GLOBAL.rpl_semi_sync_source_wait_point;
SET PERSIST rpl_semi_sync_source_whitelist = @@GLOBAL.rpl_semi_sync_source_whitelist;
SET PERSIST rpl_send_buffer_size = @@GLOBAL.rpl_send_buffer_size;
SET PERSIST rpl_stop_replica_timeout = @@GLOBAL.rpl_stop_replica_timeout;
SET PERSIST rpl_stop_slave_timeout = @@GLOBAL.rpl_stop_slave_timeout;
Expand Down Expand Up @@ -414,6 +415,7 @@ RESET PERSIST IF EXISTS rpl_semi_sync_source_trace_level;
RESET PERSIST IF EXISTS rpl_semi_sync_source_wait_for_replica_count;
RESET PERSIST IF EXISTS rpl_semi_sync_source_wait_no_replica;
RESET PERSIST IF EXISTS rpl_semi_sync_source_wait_point;
RESET PERSIST IF EXISTS rpl_semi_sync_source_whitelist;
RESET PERSIST IF EXISTS rpl_send_buffer_size;
RESET PERSIST IF EXISTS rpl_stop_replica_timeout;
RESET PERSIST IF EXISTS rpl_stop_slave_timeout;
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 connection metadata repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START REPLICA; see the 'START REPLICA 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 connection metadata repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START REPLICA; see the 'START REPLICA 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 source: Received an ACK from an unrecognized replica with UUID");
call mtr.add_suppression("Semi-sync source failed on net_flush.. before waiting for replica reply");
call mtr.add_suppression("Run function 'transmit_start' in plugin 'rpl_semi_sync_master' failed");
call mtr.add_suppression("Failed to register replica to semi-sync ACK receiver thread.*");
call mtr.add_suppression("Replica I/O for channel '': Master command COM_REGISTER_SLAVE failed: failed registering on master");
call mtr.add_suppression("Replica 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
16 changes: 16 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,16 @@
!include ../my.cnf

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

[mysqld.2]
master-retry-count=60
rpl_semi_sync_slave_enabled=1

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

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

0 comments on commit 9a3a9d6

Please sign in to comment.