What is the readlock for when copying data?

The tutorials / docs for setting up replication, suggest using a read lock before copying data eg:

SET GLOBAL read_only = ON;

What is the lock for?

My testing suggests that using a Read Lock inserts will wait, which could cause our webservers to fall over as the requests start to stack up. While jut setting read_only with no lock will cause inserts to fail quickly; which is not ideal, but shouldn’t crash the webservers )

So why does everywhere say to use the read lock? What benefit is it?


Because to set up a replication slave you need a consistent copy of your data at a single point in time.