search

Home  >  Q&A  >  body text

Will mysql master-slave and slave database lock tables cause replication blocking?

Mysql is configured with master and slave, and the slave database is used to query slow statements. If the table is locked during query, will the master database always copy it? Or will it wait until the slow query is completed before copying it?

淡淡烟草味淡淡烟草味2718 days ago1268

reply all(3)I'll reply

  • 巴扎黑

    巴扎黑2017-06-22 11:56:33

    1. Master-slave synchronization is performed through binlog. The slave library has two threads, one is responsible for receiving binlog logs, and the other is responsible for parsing the logs and writing data to the library. Therefore, master-slave synchronization generally has a certain delay.

    2. As for the issue of read-write locks, write locks are exclusive and read locks can be obtained multiple times. In Innodb, locks are divided into table locks, row locks and gap locks. It depends on your operation. If an insert operation requires locking the table, and a query locks a row in the table, you will naturally need to wait.

    reply
    0
  • phpcn_u1582

    phpcn_u15822017-06-22 11:56:33

    Please think about the question carefully again.

    According to my understanding of the question, are you sure the master library is replicating the slave library in real time? There is something wrong with this logic.

    reply
    0
  • 高洛峰

    高洛峰2017-06-22 11:56:33

    Misleading, master-slave replication. Normally, the slave library does not allow write operations other than the replication process. Query operations in the slave library will not block the replication write process. Of course, if you have to manually remove the lock When the main library synchronizes the data from the slave library to the locked record, it will wait for the lock on the slave library, so the writing actions of the slave library must be strictly controlled. All except the administrator are read-only

    reply
    0
  • Cancelreply