| 1 |
############################################################################### |
| 2 |
# Bug #18622657 SECONDS_BEHIND_MASTER DISTORTED BECAUSE OF |
| 3 |
# PREVIOUS_GTID EVENT |
| 4 |
# Problem: Previous gtid log event in relay log should not be contributed to |
| 5 |
# seconds behind master calculation. |
| 6 |
# Steps to reproduce: |
| 7 |
# 1) Try all 6 different possible rotations (new relay log files) |
| 8 |
# 2) Execute SBM after every previous_gtid_log_event execution from each |
| 9 |
# log file and make sure that timestamp is not considered for SBM |
| 10 |
# calculation. |
| 11 |
############################################################################### |
| 12 |
--source include/have_debug_sync.inc |
| 13 |
--let $rpl_skip_start_slave= 1 |
| 14 |
--source include/master-slave.inc |
| 15 |
--source include/have_binlog_format_statement.inc |
| 16 |
|
| 17 |
# Set sync debug point to calculate sbm exactly after every |
| 18 |
# previous_gtid_log_event. |
| 19 |
--connection slave |
| 20 |
SET @save_global_debug=@@GLOBAL.DEBUG; |
| 21 |
SET @@GLOBAL.DEBUG= '+d,dbug.calculate_sbm_after_previous_gtid_log_event'; |
| 22 |
|
| 23 |
# To avoid warning MTS |
| 24 |
SET @saved_replica_transaction_retries=@@global.replica_transaction_retries; |
| 25 |
SET @@global.replica_transaction_retries=0; |
| 26 |
# Previous gtid log events are generated at the time of |
| 27 |
# relay log is rotated and will be written at the top |
| 28 |
# of the relay log. There are few ways in which |
| 29 |
# relay log gets rotated. Lets find out SBM after |
| 30 |
# Previous_gtid_log_event execution in all those |
| 31 |
# of relay logs |
| 32 |
|
| 33 |
# Case-1 :At the time of server started, a new relaylog |
| 34 |
# slave-relay-bin.000001 |
| 35 |
--connection slave |
| 36 |
--let $slave_datadir=`select @@datadir` |
| 37 |
|
| 38 |
# Case-2 : Start IO thread , relay log will be rotated to |
| 39 |
# slave-relay-bin.000002 |
| 40 |
--source include/start_slave_io.inc |
| 41 |
|
| 42 |
# Case-3 : Restart IO thread, relay log will be rotated to |
| 43 |
# slave-relay-bin.000003 |
| 44 |
--source include/stop_slave_io.inc |
| 45 |
--source include/start_slave_io.inc |
| 46 |
|
| 47 |
# Case-4 Lets put (more than) 4096 data in binary log and when it |
| 48 |
# reaches slave, relaylog will be rotated (please relay-log-file-size |
| 49 |
# is set to in .opt file) to slave-relay-bin.000004/ |
| 50 |
--connection master |
| 51 |
CREATE TABLE t1(i INT); |
| 52 |
--let $i=20 |
| 53 |
while ($i > 1) |
| 54 |
{ |
| 55 |
eval INSERT INTO t1 VALUES ($i); |
| 56 |
dec $i; |
| 57 |
} |
| 58 |
DROP TABLE t1; |
| 59 |
|
| 60 |
# Case-5 (FLUSH LOGS on slave will rotate to relaylog |
| 61 |
# slave-relay-bin.000005) |
| 62 |
--connection slave |
| 63 |
FLUSH LOGS; |
| 64 |
|
| 65 |
# Case-6 (FLUSH LOGS on master will reach slave and relaylog will be rotated |
| 66 |
# at slave, generating two new slave bins slave-relay-bin.000006, |
| 67 |
# slave-relay-bin.000007) |
| 68 |
--connection master |
| 69 |
FLUSH LOGS; |
| 70 |
--source include/sync_slave_io_with_master.inc |
| 71 |
|
| 72 |
##################################### |
| 73 |
# # |
| 74 |
# Actual testing starts here. # |
| 75 |
# # |
| 76 |
##################################### |
| 77 |
|
| 78 |
# Let SQL thread read and execute all 7 slave-relay-bin's |
| 79 |
# previous_gtid_log_events and SBM cannot be greater or equal to |
| 80 |
# $idle seconds. |
| 81 |
--source include/start_slave_sql.inc |
| 82 |
|
| 83 |
# Just to fake that I/O thread started 3 mints ago, |
| 84 |
# the server changes the I/O thread start time to |
| 85 |
# now() - 180 seconds (3 mints ago) instead of now() |
| 86 |
# using debug point 'calculate_sbm_after_previous_gtid_log_event'. |
| 87 |
# But that 3 mints delay should not be seen when |
| 88 |
# some one asks for SBM after Previous_gtid_log_event and |
| 89 |
# this test script try to test that below. |
| 90 |
--let $idle=180 |
| 91 |
|
| 92 |
--let $i=0 |
| 93 |
while ($i < 7) |
| 94 |
{ |
| 95 |
SET DEBUG_SYNC="now wait_for signal.reached"; |
| 96 |
|
| 97 |
# Calcualte SBM |
| 98 |
let $sbm= query_get_value("SHOW SLAVE STATUS", Seconds_Behind_Master, 1); |
| 99 |
--let $assert_text= Seconds Behind Master should be less than $idle seconds. |
| 100 |
--let $assert_cond= $sbm < $idle |
| 101 |
--source include/assert.inc |
| 102 |
|
| 103 |
SET DEBUG_SYNC="now signal signal.done_sbm_calculation"; |
| 104 |
--inc $i |
| 105 |
} |
| 106 |
|
| 107 |
# Cleanup |
| 108 |
SET @@GLOBAL.DEBUG=@save_global_debug; |
| 109 |
SET @@global.replica_transaction_retries=@saved_replica_transaction_retries; |
| 110 |
--source include/rpl_end.inc |