Mysql – Is it safe to use pt-online-schema-change in a multimaster environment

MySQLperconapercona-toolkitpercona-tools

I have 2 MySQL servers with row-based replication between them. Both of them are masters and slaves for each other (active-active master-master setup).

If I understand it correctly pt-osc creates triggers to catch any changes while running. But from what I know triggers are not fired in a row-based replication environment. So I guess pt-osc is not able to catch changes made on the second master during the change, is it?

EDIT: While doing some tests and I saw that pt-osc was creating triggers on both masters which would cover changes from both sides. Still I'm quite unsure if I can safely do online changes in this environment.

Best Answer

The logic is more complex. (Caveat: This is not a definitive Answer to the Question, just more insight.)

  • Generally (probably in this case), the triggers should be only on the one machine.
  • RBR replicates the effect of inserts/etc, not the actual statements. That is what is needed on the Slave (aka other Master).
  • Are you 'writing' to both Masters? If so, that is a recipe for extra problems; I recommend you stop writing to the other Master while running pt-osc.

Also look into gh-ost, which uses the binlog in tricky ways. (Obviously, you have the binlog turned on.)