• unknown's avatar
    Bug #29309 Incorrect "Seconds_Behind_Master" value in SHOW SLAVE STATUS after FLUSH LOGS · bf8a85aa
    unknown authored
    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.
    bf8a85aa
rpl_replication_delay.test 1.47 KB