-
Notifications
You must be signed in to change notification settings - Fork 713
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Let Master Only Send Timestamped Heartbeat Event when waiting for new…
… trxs Summary: Let master only send HB timestamp while waiting for new trx, this will fix the SBM being inaccurate when the slave is stopped and trying to catchup from the master. Squash with: D5006919 Reviewed By: abhinav04sharma Differential Revision: D5590444 fbshipit-source-id: 620dd48
- Loading branch information
1 parent
eb7b1df
commit 746c217
Showing
4 changed files
with
258 additions
and
13 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
mysql-test/suite/rpl/include/rpl_heartbeat_zero_timestamp_input.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
################################################################################ | ||
# The workload generator on the master for rpl_heartbeat_zero_timestamp | ||
################################################################################ | ||
|
||
# Create the databases and tables | ||
|
||
--disable_query_log | ||
--disable_result_log | ||
|
||
let $i = $databases; | ||
|
||
while ($i) | ||
{ | ||
eval drop database if exists test$i; | ||
eval create database test$i; | ||
eval use test$i; | ||
eval drop table if exists t$i; | ||
eval create table t$i (a int) engine=InnoDB; | ||
dec $i; | ||
} | ||
|
||
# Run the queries | ||
|
||
while ($iter) | ||
{ | ||
let $i=$databases; | ||
|
||
while ($i) | ||
{ | ||
eval use test$i; | ||
eval insert into t$i values ($iter); | ||
dec $i; | ||
} | ||
dec $iter; | ||
} | ||
|
||
--enable_result_log | ||
--enable_query_log |
38 changes: 38 additions & 0 deletions
38
mysql-test/suite/rpl/r/rpl_heartbeat_zero_timestamp.result
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
include/master-slave.inc | ||
[connection master] | ||
include/rpl_set_gtid_mode.inc | ||
include/stop_slave.inc | ||
set @save.slave_parallel_workers= @@global.slave_parallel_workers; | ||
SET @@global.slave_parallel_workers= 4; | ||
CHANGE MASTER TO MASTER_AUTO_POSITION=1; | ||
include/start_slave.inc | ||
SET GLOBAL DEBUG="+d, send_zero_hb_event"; | ||
include/sync_slave_sql_with_master.inc | ||
include/stop_slave.inc | ||
CHANGE MASTER TO MASTER_HEARTBEAT_PERIOD=0.1; | ||
include/start_slave.inc | ||
include/assert.inc [Seconds behind master should be bigger than zero after creating the lag for MTS] | ||
include/sync_slave_sql_with_master.inc | ||
include/stop_slave.inc | ||
SET @@global.slave_parallel_workers= 0; | ||
include/start_slave.inc | ||
include/assert.inc [Seconds behind master should be bigger than zero after creating the lag for non-MTS] | ||
use test4; | ||
drop table if exists t4; | ||
drop database if exists test4; | ||
use test3; | ||
drop table if exists t3; | ||
drop database if exists test3; | ||
use test2; | ||
drop table if exists t2; | ||
drop database if exists test2; | ||
use test1; | ||
drop table if exists t1; | ||
drop database if exists test1; | ||
SET GLOBAL DEBUG="-d, send_zero_hb_event"; | ||
include/sync_slave_sql_with_master.inc | ||
include/stop_slave.inc | ||
set @@global.slave_parallel_workers= @save.slave_parallel_workers; | ||
CHANGE MASTER TO MASTER_HEARTBEAT_PERIOD=60.000; | ||
include/start_slave.inc | ||
include/rpl_end.inc |
119 changes: 119 additions & 0 deletions
119
mysql-test/suite/rpl/t/rpl_heartbeat_zero_timestamp.test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
################################################################################ | ||
# Testing the second behind master is correct with timestamp in HB event | ||
################################################################################ | ||
|
||
source include/not_valgrind.inc; | ||
source include/not_parallel.inc; | ||
|
||
# Start a new master-slave | ||
--disable_warnings | ||
--source include/have_binlog_format_row.inc | ||
--source include/master-slave.inc | ||
--source include/rpl_set_gtid_mode.inc | ||
--enable_warnings | ||
|
||
--source include/have_gtid.inc | ||
|
||
# Enable MTS | ||
--connection slave | ||
--source include/stop_slave.inc | ||
set @save.slave_parallel_workers= @@global.slave_parallel_workers; | ||
SET @@global.slave_parallel_workers= 4; | ||
CHANGE MASTER TO MASTER_AUTO_POSITION=1; | ||
--source include/start_slave.inc | ||
|
||
# Run a few queries on the master to create skip scneario | ||
--connection master | ||
SET GLOBAL DEBUG="+d, send_zero_hb_event"; | ||
let $databases = 4; | ||
let $iter = 10; | ||
--source suite/rpl/include/rpl_heartbeat_zero_timestamp_input.inc | ||
# Make sure that the slave has caught up to the master | ||
--source include/sync_slave_sql_with_master.inc | ||
|
||
|
||
# Stop the slave | ||
--connection slave | ||
--source include/stop_slave.inc | ||
|
||
|
||
# Create a lag on the master by running many queries | ||
--connection master | ||
let $databases = 4; | ||
let $iter = 10000; | ||
--source suite/rpl/include/rpl_heartbeat_zero_timestamp_input.inc | ||
|
||
|
||
# Now start slave again so that we can get some HB during skipping | ||
--connection slave | ||
# Create some lag | ||
let $lagging_sec = 5; | ||
sleep $lagging_sec; | ||
# Set HB event interval small enough | ||
let $old_slave_heartbeat_period= query_get_value(SHOW GLOBAL STATUS LIKE 'slave_heartbeat_period', Value, 1); | ||
let $new_slave_heartbeat_period= 0.1; | ||
# Since the skiping is really small, after this, for sure we should get the event | ||
let $skipping_guarantee_sleep= 1; | ||
eval CHANGE MASTER TO MASTER_HEARTBEAT_PERIOD=$new_slave_heartbeat_period; | ||
--source include/start_slave.inc | ||
|
||
# Sleep so that we for sure get the binlog events | ||
sleep $skipping_guarantee_sleep; | ||
let $sbm= query_get_value("SHOW SLAVE STATUS", Seconds_Behind_Master, 1); | ||
# Assertion | ||
--let $assert_text = Seconds behind master should be bigger than zero after creating the lag for MTS | ||
--let $assert_cond = $sbm > $lagging_sec; | ||
--source include/assert.inc | ||
|
||
|
||
# Catch up | ||
--connection master | ||
--source include/sync_slave_sql_with_master.inc | ||
|
||
|
||
# Now test by disabling MTS | ||
--connection slave | ||
--source include/stop_slave.inc | ||
SET @@global.slave_parallel_workers= 0; | ||
--source include/not_mts_slave_parallel_workers.inc | ||
|
||
|
||
# Create a lag on the master | ||
--connection master | ||
let $databases = 4; | ||
let $iter = 10000; | ||
--source suite/rpl/include/rpl_heartbeat_zero_timestamp_input.inc | ||
|
||
|
||
--connection slave | ||
# Create some lag | ||
sleep $lagging_sec; | ||
--source include/start_slave.inc | ||
# Sleep so that we for sure get the HB events | ||
sleep $skipping_guarantee_sleep; | ||
let $sbm= query_get_value("SHOW SLAVE STATUS", Seconds_Behind_Master, 1); | ||
# Assertion | ||
--let $assert_text = Seconds behind master should be bigger than zero after creating the lag for non-MTS | ||
--let $assert_cond = $sbm > $lagging_sec | ||
--source include/assert.inc | ||
|
||
# clean up | ||
--connection master | ||
let $i = $databases; | ||
while ($i) | ||
{ | ||
eval use test$i; | ||
eval drop table if exists t$i; | ||
eval drop database if exists test$i; | ||
dec $i; | ||
} | ||
SET GLOBAL DEBUG="-d, send_zero_hb_event"; | ||
--source include/sync_slave_sql_with_master.inc | ||
|
||
--connection slave | ||
--source include/stop_slave.inc | ||
set @@global.slave_parallel_workers= @save.slave_parallel_workers; | ||
eval CHANGE MASTER TO MASTER_HEARTBEAT_PERIOD=$old_slave_heartbeat_period; | ||
--source include/start_slave.inc | ||
|
||
--source include/rpl_end.inc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters