Found a very good explanation of how Seconds_behind_master is computed in this bug report.
http://bugs.mysql.com/bug.php?id=2826
Here's how Seconds_behind_master is computed.
* When the slave connects to the master (when the slave I/O thread connects to the
master),
it does a = SELECT UNIX_TIMESTAMP() on master,
and b= SELECT UNIX_TIMESTAMP() on slave, and computes c=b-a.
* Every statement executed on the master is stored on the master's binary log together
with the timestamp when it was executed.
* So when the slave SQL thread reads a statement from the binary log, it executes it and
then it does:
seconds_behind_master= SELECT UNIX_TIMESTAMP() on slave
- timestamp of the master's binary log event
- c
Thursday, February 10, 2011
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment