<div dir="ltr"><div><div>Always fearing doing queries on a lagged replica on labs? Not anymore!<br><br></div>While Betacommand's tool [0] was very useful, it was also very inaccurate, as it tried to check the lag by looking at the last rows updated, which can be a lot of time on the least popular wikis.<br><br></div>What I offer now is sub-second accurate lag measuring, by writing on the production masters the current time, in microseconds, every 0.5 seconds and making that available on all hosts (using this tool [1]). So, it is more accurate than SHOW SLAVE STATUS, because it compares the difference with the original master, and it will work even if replication is broken.<br clear="all"><div><div><div><br></div><div>To read it, just do SELECT * FROM heartbeat_p.heartbeat;<br></div><div>And you will get:<br>+-------+----------------------------+------+<br>| shard | last_updated               | lag  |<br>+-------+----------------------------+------+<br>| s6    | 2015-11-25T20:20:32.000980 |    0 |<br>| s2    | 2015-11-25T20:20:32.001030 |    0 |<br>| s7    | 2015-11-25T20:20:32.001070 |    0 |<br>| s3    | 2015-11-25T20:20:32.001000 |    0 |<br>| s4    | 2015-11-25T20:20:32.000920 |    0 |<br>| s1    | 2015-11-25T20:20:32.000740 |    0 |<br>| s5    | 2015-11-25T20:20:32.000830 |    0 |<br>+-------+----------------------------+------+<br></div><div><br>Read the detailed documentation on: [2]<br><br></div><div>Use it, create a web page if you want to make it public! Report a ticket if it gets too high! Report a ticket if you need more info (a record per wiki?). But I wanted to give you the essentials, and you can build yourselves on top of that.<br><br></div><div>Only 2 know bugs:<br></div><div>- There is microsecond accuracy, but it cannot be used until a bug in MariaDB is fixed [3]<br></div><div>- enwiki will only report s1 lag until that server is restarted due to some existing filters. We will schedule that at some time in the future.<br></div><div><br>[0]<<a href="http://tools.wmflabs.org/betacommand-dev/cgi-bin/replag">http://tools.wmflabs.org/betacommand-dev/cgi-bin/replag</a>><br>[1]<<a href="https://www.percona.com/doc/percona-toolkit/2.2/pt-heartbeat.html">https://www.percona.com/doc/percona-toolkit/2.2/pt-heartbeat.html</a>><br>[2]<<a href="https://wikitech.wikimedia.org/wiki/Help:Tool_Labs/Database#Identifying_lag">https://wikitech.wikimedia.org/wiki/Help:Tool_Labs/Database#Identifying_lag</a>><br>[3]<<a href="https://mariadb.atlassian.net/browse/MDEV-9175">https://mariadb.atlassian.net/browse/MDEV-9175</a>><br>-- <br><div class="gmail_signature"><div dir="ltr"><div>Jaime Crespo<br></div><<a href="http://wikimedia.org" target="_blank">http://wikimedia.org</a>><br></div></div>
</div></div></div></div>