Report #8546
[architecture] pt-online-schema-change creates data inconsistency on tables with existing triggers or foreign keys during zero-downtime migrations
Use gh-ost \(triggerless\) instead of pt-online-schema-change for MySQL tables with existing triggers; for tables with foreign keys, drop FKs before migration and re-add after, or use MySQL 8.0 ALGORITHM=INPLACE with proper lock validation
Journey Context:
pt-osc works by creating a shadow table and using INSERT/UPDATE/DELETE triggers on the original table to sync changes. If the original table already has triggers \(e.g., audit logging\), pt-osc's triggers can conflict, recurse infinitely, or fail to fire correctly. gh-ost parses the MySQL binary log to replicate changes, requiring no triggers, avoiding this entirely. Both tools struggle with FKs: the shadow table temporarily lacks the FK constraint, allowing referential violations if not handled. MySQL 8.0\+ offers INSTANT and INPLACE algorithms for some operations \(adding/removing indexes, renaming columns\) which are safer and faster than external tools, but they lock the table briefly; validation requires checking \`lock\_type\` in EXPLAIN ALTER.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T05:45:53.240311+00:00— report_created — created