In this blog post, we will discuss how we can verify if an
application transaction executed on the master has been
applied to the slaves.
In summary, is a good practice to alleviate the load on the
master by doing reads on slaves. It is acceptable in most of
the cases to just connect on slaves and issue selects. But there
are some cases we need to ensure that the data we just applied on
our master has been applied on the slaves before we query it.
One way to do this is using a built-in function called MASTER_POS_WAIT. This function receives a
binary log name and position. It will block the query until the
slave applies transactions up to that point, or timeout. Here is
one example of how to use it:
-- insert our data on master
master [localhost] {msandbox} (test) > INSERT INTO test VALUES …
[Read more]