zoukankan      html  css  js  c++  java
  • Seconds_Behind_Master的计算

         MySQL复制中seconds_behind_master的计算
         
    1.seconds_behind_master定义为从库相对于主库的延迟时间。
        具体的计算公式为:
            clock_of_slave - last_timestamp_executed_by_SQL_thread-clock_diff_with_master.
            
        备注:位于rpl_mi.h中定义了clock_diff_with_master,该值为从库相对于主库的时间差。
              /*
         The difference in seconds between the clock of the master and the clock of
         the slave (second - first). It must be signed as it may be <0 or >0.
         clock_diff_with_master is computed when the I/O thread starts; for this the
         I/O thread does a SELECT UNIX_TIMESTAMP() on the master.
         "how late the slave is compared to the master" is computed like this:
         clock_of_slave - last_timestamp_executed_by_SQL_thread - clock_diff_with_master
      */
      long clock_diff_with_master;
      //  clock_diff_with_master
      // mi->clock_diff_with_master=
          (long) (time((time_t*) 0) - strtoul(master_row[0], 0, 10));
          master_row[0]就是在主库上执行SELECT UNIX_TIMESTAMP()的操作。
          从如下到(rpl_slave.cc)可以看出:
          start_slave_thread->  //启动start slave
                handle_slave_io-> //启动start io thread
                    get_master_version_and_clock //获取当前slave和主机之间的时间差(clock_diff_with_master)
                    
       /*
        Used to defer stopping the SQL thread to give it a chance
        to finish up the current group of events.
        The timestamp is set and reset in @c sql_slave_killed().
      */
      time_t last_event_start_time; //slave端最后执行的reply log的最后一个事件的时间
      
        
  • 相关阅读:
    HDU 2089 不要62 【数位dp】
    HDU 3507 Print Article(dp+斜率优化)
    HDU 1078 FatMouse and Cheese【记忆化搜索】
    codeforces 366C Dima and Salad 【限制性01背包】
    HDU
    HDU 2844 Coins 【多重背包】(模板)
    hdu 2167 方格取数 【状压dp】(经典)
    poj 1160 Post Office 【区间dp】
    Poj
    HDU 1542 矩形面积并【离散化+线段树+扫描线】
  • 原文地址:https://www.cnblogs.com/innobase/p/4588445.html
Copyright © 2011-2022 走看看