Transactions and Replication Master + Slave

I want to figure it out a bit. I have a master + slaves setting. I have one master and 3 slaves. All entries ( INSERT|UPDATE|DELETE) go to the main. All readings ( SELECT) go to one of the slaves, which is randomly selected. All my tables use the InnoDB storage engine.

I'm curious how MySQL / InnoDB handles transactions in this setup. If MySQL writes every change inside a transaction to binlog, everything should be fine. However, I see that big problems arise if the bitlog is not written until the transaction is completed.

Can someone explain what happens inside MySQL during a replication transaction?

+5
source share
2 answers

Typically, if a transaction is not written to the binary log before it is committed. Assuming the table is transactional, all transaction statements are grouped into a single BEGIN \ COMMIT statement.

0
source

According to this , slaves can only see changes after a transaction.

Transactions that are not performed by the wizard do not affect replication at all. MySQL replication is based on a binary log, where MySQL writes SQL statements that modify data. A transaction failure (for example, due to a foreign key violation or due to its rollback) is not written to the binary log, therefore, it is not sent to the slaves.

And this confirms:

-. .

0

All Articles