Skip to content

Instantly share code, notes, and snippets.

# HOW REPLICATION WORKS
IO_THREAD connects to a master, reads binary log events from the master as they come in and just copies them over to a local log file called relay log.
SQL_THREAD reads events from a relay log stored locally on the replication slave and then applies them as fast as possible.
There could be two reasons for delay in replication:
1. IO_THREAD delay
2. SQL_THREAD deplay
# HOW TO INDENTIFY REPLICATION LAG
--
-- To create the group
--
-- Create a ro_group (readonly group)
CREATE ROLE ro_group;
-- Grant access to existing tables
GRANT USAGE ON SCHEMA public TO ro_group;