Skip to content

Commit

Permalink
Fix rpl_wait_for_semi_sync_ack feature
Browse files Browse the repository at this point in the history
Summary:
Fixed the following:
1. Initializing last acked position to what is retrived from engine during
server startup. This makes sure that lagging async slaves are able to catchup
until the last acked position after master restarts.
2. Resetting last acked posistion when `RESET MASTER` is issued. This makes sure
that after the binlogs are reset we wait for acks.
3. Signalling/updating last acked positions only on events that were actually
acked by the semi-sync slave (like the Xid event of the last trx in a group
commit). This is done by signalling inside of the plugin
(ReplSemiSyncMaster::reportReplyBinlog).
4. Signalling/updating on trxs skipped on semi-sync slave connection while
searching for first gtid connection

Reviewed By: hermanlee

Differential Revision: D15384707

fbshipit-source-id: f8917a9
  • Loading branch information
abhinav04sharma authored and facebook-github-bot committed Jun 7, 2019
1 parent d4cc605 commit b42b911
Show file tree
Hide file tree
Showing 11 changed files with 469 additions and 172 deletions.
124 changes: 102 additions & 22 deletions mysql-test/suite/rpl/r/rpl_wait_for_semi_sync_ack.result
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,46 @@ include/rpl_connect.inc [creating master]
include/rpl_connect.inc [creating master1]
include/rpl_connect.inc [creating async_slave]
include/rpl_connect.inc [creating semi_sync_slave]
set @save.rpl_wait_for_semi_sync_ack= @@global.rpl_wait_for_semi_sync_ack;
set @@global.rpl_wait_for_semi_sync_ack= true;
set @save.rpl_semi_sync_master_timeout= @@global.rpl_semi_sync_master_timeout;
set @@global.rpl_semi_sync_master_timeout= 10000000;
call mtr.add_suppression("Error while waiting for semi-sync ACK on dump thread");
call mtr.add_suppression("Slave SQL: Request to stop slave SQL Thread received");
include/stop_slave.inc
change master to master_auto_position = 1;
include/start_slave.inc
include/stop_slave.inc
change master to master_auto_position = 1;
include/start_slave.inc
create table t1(a int);
include/sync_slave_sql_with_master.inc
include/sync_slave_sql_with_master.inc
set @@global.debug= '+d,before_semi_sync_reply';
create table t1 (a int);
"Store the current cursor for and async slave"
"Store the last acked pos"
begin;
insert into t1 values(1);
insert into t1 values(2);
insert into t1 values(3);
commit;
SET DEBUG_SYNC='now WAIT_FOR reached';
"Async Slave: Should not contain any tables"
show tables;
Tables_in_test
"Async Slave: t1 should not contain any rows"
select count(*) from t1;
count(*)
0
"Async slave's cursor should not move"
include/assert.inc [Async slave cursor should not move]
"Last acked pos should not move"
include/assert.inc [Last acked pos should not move]
SET DEBUG_SYNC='now SIGNAL continue';
"Master: Should contain t1"
show tables;
Tables_in_test
t1
set @@global.debug= '-d,before_semi_sync_reply';
"Master: t1 should contain three rows"
select count(*) from t1;
count(*)
3
include/sync_slave_sql_with_master.inc
"Async Slave: Should contain t1"
show tables;
Tables_in_test
t1
"Async Slave: t1 should contain three rows now that trx is ACKed"
select count(*) from t1;
count(*)
3
set @@global.debug= '+d,before_semi_sync_reply';
create table t2(a int);
SET DEBUG_SYNC='now WAIT_FOR reached';
"Killing thread"
Expand All @@ -40,6 +59,7 @@ show tables;
Tables_in_test
t1
SET DEBUG_SYNC='now SIGNAL continue';
set @@global.debug= '-d,before_semi_sync_reply';
"Tables on master"
show tables;
Tables_in_test
Expand All @@ -56,6 +76,7 @@ show tables;
Tables_in_test
t1
t2
set @@global.debug= '+d,before_semi_sync_reply';
create table t3(a int);
SET DEBUG_SYNC='now WAIT_FOR reached';
"Switching off rpl_semi_sync_master_enabled while async thread is waiting for ack"
Expand All @@ -70,8 +91,8 @@ t3
SET DEBUG_SYNC='now SIGNAL continue';
"Switching rpl_semi_sync_master_enabled back on"
set @@global.rpl_semi_sync_master_enabled = 1;
stop slave;
start slave;
include/stop_slave.inc
include/start_slave.inc
"Waiting till semi-sync slave is caught up"
include/sync_slave_sql_with_master.inc
show tables;
Expand All @@ -92,10 +113,9 @@ t2
t3
t4
SET DEBUG_SYNC='now SIGNAL continue';
set @@global.debug= '-d,before_semi_sync_reply';
"Switching rpl_wait_for_semi_sync_ack back on"
set @@global.rpl_wait_for_semi_sync_ack = 1;
stop slave;
start slave;
"Waiting till semi-sync slave is caught up"
include/sync_slave_sql_with_master.inc
show tables;
Expand All @@ -104,13 +124,73 @@ t1
t2
t3
t4
"Stopping async slave to simulate lag"
include/stop_slave.inc
"Generating traffic on the master"
create table t5(a int);
insert into t5 values(1);
insert into t5 values(2);
flush logs;
insert into t5 values(3);
insert into t5 values(4);
flush logs;
include/sync_slave_sql_with_master.inc
"Restarting master"
include/rpl_restart_server.inc [server_number=1]
"Starting async slave"
include/start_slave.inc
"Waiting till async slave is caught up"
include/sync_slave_sql_with_master.inc
include/stop_slave.inc
include/stop_slave.inc
set @gtid_exec= @@global.gtid_executed;
reset master;
"Last acked pos should be empty"
show status like 'Rpl_last_semi_sync_acked_pos';
Variable_name Value
Rpl_last_semi_sync_acked_pos :0
set @@global.gtid_purged= @gtid_exec;
purge binary logs to 'binlog';
include/start_slave.inc
include/start_slave.inc
set @@global.debug= '+d,before_semi_sync_reply';
create table t6 (a int);
SET DEBUG_SYNC='now WAIT_FOR reached';
"Async Slave: Should not contain t6"
show tables;
Tables_in_test
t1
t2
t3
t4
t5
SET DEBUG_SYNC='now SIGNAL continue';
set @@global.debug= '-d,before_semi_sync_reply';
"Master: Should contain t6"
show tables;
Tables_in_test
t1
t2
t3
t4
t5
t6
include/sync_slave_sql_with_master.inc
"Async Slave: Should contain t6"
show tables;
Tables_in_test
t1
t2
t3
t4
t5
t6
drop table t1;
drop table t2;
drop table t3;
drop table t4;
set @@global.rpl_wait_for_semi_sync_ack= @save.rpl_wait_for_semi_sync_ack;
set @@global.rpl_semi_sync_master_timeout= @save.rpl_semi_sync_master_timeout;
drop table t5;
drop table t6;
include/sync_slave_sql_with_master.inc
include/sync_slave_sql_with_master.inc
include/rpl_end.inc
4 changes: 4 additions & 0 deletions mysql-test/suite/rpl/t/rpl_wait_for_semi_sync_ack.cnf
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ log-slave-updates
gtid-mode=ON
enforce-gtid-consistency
rpl_semi_sync_master_enabled= 1
rpl_wait_for_semi_sync_ack= 1
rpl_semi_sync_master_timeout= 10000000
rpl_semi_sync_master_wait_no_slave= 1

[mysqld.2]
log-slave-updates
Expand All @@ -16,6 +19,7 @@ log-slave-updates
gtid-mode=ON
enforce-gtid-consistency
rpl_semi_sync_slave_enabled= 1
rpl_semi_sync_master_wait_no_slave= 1

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

0 comments on commit b42b911

Please sign in to comment.