Reference official website: https://dev.mysql.com/doc/refman/5.7/en/replication-implementation-details.html
The MySQL replication feature is implemented through three threads, including the Lord's Binlog dump tread and the SQL thread from the top, I/O ttread
Binlog Dump Thread
Master creates the Binlog dump thread, which is used to send Binlog events to slave when it connects to master, and the dump thread reads every event that will be sent to slave every time
First get lock in binary log, and then release after reading.
Slave I/O thread
When execution is START SLAVE performed on the slave side, Slave creates an I/O thread connection to the master active read dump thread that writes the latest Binlog events to the local relay log
Slave SQL Thread
Slave create SQL thread to read the event from the relay log and apply
The I/O thread reads the event without slowing down the server execution, even if the slave I/O thread is stopped for a while, and when it is turned on again, it can quickly get all the
The latest Binlog content to relay log, even if the SQL thread has a significant delay. If slave is stopped before SQL thread finishes using all relay logs, the I/O thread gets at least
All the transaction logs that have occurred on master so far to relay log, ensuring secure replication, to be applied at the next boot of slave.
If Maser does not see the Binlog dump thread through show processlist, replication has stopped.
MySQL Replication principle