It is possible to replicate transactional tables on the master
using nontransactional tables on the slave. For example, you can
replicate an InnoDB
master table as a
MyISAM
slave table. However, if you do this,
there are problems if the slave is stopped in the middle of a
BEGIN
/COMMIT
block because the slave restarts at the beginning of the
BEGIN
block.
In situations where transactions mix updates to transactional
and nontransactional tables, the order of statements in the
binary log is correct, and all needed statements are written to
the binary log even in case of a
ROLLBACK
.
However, when a second connection updates the nontransactional
table before the first connection's transaction is complete,
statements can be logged out of order because the second
connection's update is written immediately after it is
performed, regardless of the state of the transaction being
performed by the first connection.
Due to the nontransactional nature of MyISAM
tables, it is possible to have a statement that only partially
updates a table and returns an error code. This can happen, for
example, on a multiple-row insert that has one row violating a
key constraint, or if a long update statement is killed after
updating some of the rows. If that happens on the master, the
slave thread exits and waits for the database administrator to
decide what to do about it unless the error code is legitimate
and execution of the statement results in the same error code on
the slave. If this error code validation behavior is not
desirable, some or all errors can be masked out (ignored) with
the --slave-skip-errors
option.
If you update transactional tables from nontransactional tables
inside a
BEGIN
/COMMIT
sequence, updates to the binary log may be out of synchrony with
table states if the nontransactional table is updated before the
transaction commits. This occurs because the transaction is
written to the binary log only when it is committed.
In situations where transactions mix updates to transactional
and nontransactional tables, the order of statements in the
binary log is correct, and all needed statements are written to
the binary log even in case of a
ROLLBACK
.
However, when a second connection updates the nontransactional
table before the first connection's transaction is complete,
statements can be logged out of order because the second
connection's update is written immediately after it is
performed, regardless of the state of the transaction being
performed by the first connection.
You should avoid transactions that update both transactional and nontransactional tables in a replication environment.
When the storage engine type of the slave is nontransactional, transactions on the master that mix updates of transactional and nontransactional tables should be avoided because they can cause inconsistency of the data between the master's transactional table and the slave's nontransactional table. That is, such transactions can lead to master storage engine-specific behavior with the possible effect of replication going out of synchrony. MySQL does not issue a warning about this currently, so extra care should be taken when replicating transactional tables from the master to nontransactional tables on the slaves.
User Comments
Add your own comment.