mirror of
https://github.com/MariaDB/server.git
synced 2025-01-31 11:01:52 +01:00
bf8a85aa56
Report claims that Seconds_behind_master behaves unexpectedly. Code analysis shows that there is an evident flaw in that treating of FormatDescription event is wrong so that after FLUSH LOGS on slave the Seconds_behind_master's calculation slips and incorrect value can be reported to SHOW SLAVE STATUS. Even worse is that the gap between the correct and incorrect deltas grows with time. Fixed with prohibiting changes to rpl->last_master_timestamp by artifical events (any kind of). suggestion as comments is added how to fight with lack of info on the slave side by means of new heartbeat feature coming. The test can not be done ealily fully determistic. sql/log_event.cc: changing timestamp is affirmed only by non-artificial events. Artifical FD won't change it anymore. The simulation code is off unless server is started with the args from the opt-file. The simulation code assumes that it will execute specific schedule generated by rpl_replication_delay.test. sql/slave.cc: Comments are changed to announce a new possibility to cope with Seconds_behind_master jumping due to EOF special treatment (reset of the timestamp) mysql-test/suite/manual/r/rpl_replication_delay.result: result are not deterministic though there are comments saying the most probable expected value for Seconds_behind_master mysql-test/suite/manual/t/rpl_replication_delay-slave.opt: bug emulation mysql-test/suite/manual/t/rpl_replication_delay.test: specic test for bug#29309. It's hard to make it reliable as it deals with timestamps. (a way to automate the test like this is to have I_S table for show slave status' fields) A possible way to check results is to run grep -i 'show\|seconds' < suite/manual/r/rpl_replication_delay.reject and to get the lines like these: show slave status /* Second_behind reports 0 */;; Seconds_Behind_Master 0 show slave status /* bug emulated: reports slave threads starting time about 3*3 not 3 secs */;; Seconds_Behind_Master 9 show slave status /* reports the correct diff with master query time about 3+3 secs */;; Seconds_Behind_Master 6 Due to time discreteness of time the reported numbers may slightly vary. That's why the test is not reliable.
71 lines
1.5 KiB
Text
71 lines
1.5 KiB
Text
#
|
|
# Testing replication delay reporting (bug#29309)
|
|
# there is an unavoidable non-determinism in the test
|
|
# please compare the results with the comments
|
|
#
|
|
|
|
|
|
source include/master-slave.inc;
|
|
|
|
connection master;
|
|
#connection slave;
|
|
sync_slave_with_master;
|
|
--replace_result $DEFAULT_MASTER_PORT DEFAULT_MASTER_PORT
|
|
--replace_column 1 # 8 # 9 # 23 #
|
|
--query_vertical show slave status /* Second_behind reports 0 */;
|
|
sleep 3;
|
|
|
|
### bug emulation
|
|
|
|
connection master;
|
|
drop table if exists t1;
|
|
create table t1 (f1 int);
|
|
sleep 3;
|
|
|
|
#connection slave;
|
|
sync_slave_with_master;
|
|
flush logs /* contaminate rli->last_master_timestamp */;
|
|
|
|
connection slave;
|
|
lock table t1 write;
|
|
|
|
connection master;
|
|
insert into t1 values (1);
|
|
|
|
sleep 3;
|
|
|
|
connection slave;
|
|
--replace_result $DEFAULT_MASTER_PORT DEFAULT_MASTER_PORT
|
|
--replace_column 1 # 8 # 9 # 23 #
|
|
--query_vertical show slave status /* bug emulated: reports slave threads starting time about 3*3 not 3 secs */;
|
|
unlock tables;
|
|
|
|
connection master;
|
|
sync_slave_with_master;
|
|
|
|
### bugfix
|
|
|
|
|
|
connection slave;
|
|
flush logs /* this time rli->last_master_timestamp is not affected */;
|
|
lock table t1 write;
|
|
|
|
connection master;
|
|
insert into t1 values (2);
|
|
sleep 3;
|
|
|
|
connection slave;
|
|
--replace_result $DEFAULT_MASTER_PORT DEFAULT_MASTER_PORT
|
|
--replace_column 1 # 8 # 9 # 23 #
|
|
--query_vertical show slave status /* reports the correct diff with master query time about 3+3 secs */;
|
|
unlock tables;
|
|
|
|
connection master;
|
|
drop table t1;
|
|
|
|
#connection slave;
|
|
sync_slave_with_master;
|
|
|
|
|
|
# End of tests
|
|
|