Mark Riddoch <mark.riddoch@skysql.com> writes:
We have been looking for a cheap way to find this out and came up with an idea for MariaDB 10 that might be good to discuss. If we use the global transaction ID we can get the current master ID and the current GTID form each slave and use them to compare and discover if a slave is lagging based on a single connection from a client or the entire server. Clearly we can get this by jus asking in a polling monitor loop, but what would be really good would be to have a function in MariaDB that we could call that would wait for the GTID id to change and return the new GTID. THen we could have a monitor that makes this blocking call and get's to know the new GTID very quickly compered to having to have some form of poling loop, which would limit to the rate of change that could be detected to the polling rate of the monitor.
See here: http://kristiannielsen.livejournal.com/18308.html It's similar to what you describe. MASTER_GTID_WAIT() is already in 10.0 (I can't remember if it is in 10.0.8, else it will be in 10.0.9). Note that if you really want to wait for any change in GTID on a slave, you can just take the current @@gtid_slave_pos, add one to every sequence number, and wait for that. - Kristian.