I'm working on an implementation of a mysql slave precache tool as described by Paul Tuckfield at last year's User conference.
I can easily tell where the SQL Thread is currently is reading from in the local relay log, but it's a harder problem to solve when I want to scan ahead in that log some number of binlog entries and find a valid position. I can simply add to the position some number of bytes, but then I have to stop and loop through calls to 'mysqlbinlog' until I get a position that doesn't throw an error.
This turns out to be a pretty expensive operation, and I'm having a problem where by the time I find a good position and can start my precacher, the slave is already past me!
Does anyone have any clever ways to find good binary log positions besides this (this is in ruby, in case you're wondering):
def mysqlbinlog_cmd( position, length )