soundcloud/large-hadron-migrator — comment on commit c79bd93830f8fb67e1a6b3a0a6a69a65caa4f8ed
File:  line 0
By lgierth:

The copying makes use of `INSERT IGNORE`, so rows that have already been replayed by the trigger will simply be dropped. Thanks for the docs notice, we'll fix that!

I'm not sure why both tables are locked before switching, but I think it's just to make the actual renaming faster. `ALTER TABLE` does already lock the table, but it would lock the destination table _after_ renaming the original table and might wait for some operations to finish before actually renaming it. Sounds rather exotic to me, but makes sense as we want migrations to be as predictable as possible. Maybe @grobie or @purzelrakete can further elaborate on this.

The renaming is _not_ atomic. You could use `RENAME TABLE` to do this atomically, but in the MySQL versions we use, there is at least on bug with regard to replication that can cause data loss.