← Back to team overview

maria-developers team mailing list archive

Re: 答复: 答复: 答复: MDEV-520: consider parallel replication patch from taobao patches


Stewart Smith <stewart@xxxxxxxxxxxxxxxx> writes:

> What about just run those txns serially rather than attempting to do in
> parallel?

Maybe. Well, first we need to generalise "MyISAM" and "InnoDB" to a general
way of putting any storage engine into one or the other category. I assume
Monty or Serg can help me figure out how to do this.

> As soon as you see a MyISAM operation, have a thread that waits for all
> replication up to that point to be committed, and then do the MyISAM
> operation. (as there's no reason why other replication couldn't be
> applied at the same time... after all, MyISAM isn't crash safe so would
> never be consistent with InnoDB txns).

Well, consistency is not just about crash safety.

If you do out-of-order parallel replication, then the application can see a
state on the slave that is impossible to reach on the master. Only the
application developer can say if this is ok for the application. In the
general case, it will not be. So this needs explicit configuration.

But with an MVCC engine like InnoDB, changes only become visible to other
transactions after COMMIT. So even if we apply the transactions in parallel in
a potentially different order than on the master, if we commit in the same
order as on the master, then there is no way for an application to see a state
on the slave that did not also exist on the master. Thus in-order parallel
replication is correct and can be safely enabled always.

MyISAM is not MVCC nor does it have COMMIT, so it seems by default we should
do what you suggest: run MyISAM transactions serially. In fact they have to
run serially with respect to InnoDB transactions also, to avoid getting the
slave into a state that might be invalid to the application.

On the other hand, if an application can tolerate out-of-order, then it would
be very useful to support also parallel apply for MyISAM. So it could be a
configuration to allow out-of-order for MyISAM also. Of course, this will only
be possible for updates to different MyISAM tables, due to table-level
locking. Possible INSERTs could be allowed out-of-order, as they can sometimes
happen in parallel even for MyISAM.

 - Kristian.

Follow ups