I have two MySQL instances (Percona server 5.6.31) in Master-Slave replication setup.
I have set the below configuration:
- ROW based replication is set.
- Transaction Isolation is set to read-committed.
Today, there was a insert going on in my Master. It was in the format
INSERT INTO table1 SELECT * FROM table2
Table 2 has 200 million rows.
Though the number of insert records was only 5000 but the operation lasted for 30 mins. I observed replication lag during the insert operation.
I have load infile disabled due to security concerns. Hence I can't insert using that as well.
I went this article from Percona which says that this can be resolved if txn isolation is used as ROW and versions above 5.1 that this is resolved.
- In what way I can make my slave to be in sync with Master in such conditions?
- Why does the slave lag here?
Best Answer
The semantics of that statement is to do it all in a single transaction. This may well exceed
innodb_lock_wait_timeout
and/or cause other operations to exceed it.With RBR, each of the 200M rows will be separately fed through the replication stream; this is a huge amount of data (more than the table size, itself).
The Slave cannot handle any other replication during the execution of the 200M individual inserts.
What to do? First, explain more about the situation.
SHOW CREATE TABLE table
. (Need to see indexes, FKs, etc)