-
Notifications
You must be signed in to change notification settings - Fork 147
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support tables with triggers and foreign keys #28
Comments
Hi @bancer, thanks for the note. I'll address this in two parts for each limitation. Supporting this style of schema changes for tables with foreign key checks enabled is not possible because in the process of rebuilding the table with the new schema, we need to re-insert the data it contained which mean it will not be able to satisfy those foreign key checks against tables that are not being rebuilt. Any method to get around this has to come from knowledge of the specific application and data semantics and is not something that a tool like OSC can account for. If we disabled the foreign key checks for the duration of the schema change, we would have no assurances that the data in the new table satisfies all the foreign key constraints because MySQL does not scan and cross-reference them and all the data they point to when enabling it. Existing triggers are not supported because OSC uses a few triggers to track changes to the table it's rebuilding. Existing triggers could conflict with the triggers OSC has to put in place during its operation, without those we can't rebuild the table with the new schema while still being able to catch up to the changes the table has had while this was all happening. Github released their online mysql schema changing system, "gh-ost" which uses "ROW" format binlogs to do the catchup instead of triggers like OSC uses, which gets around that limitation at least. You can learn more about it here: https://github.com/github/gh-ost. For OSC we have it in mind to use row-based binlogs for the catchup (as described in issue #11) so someday OSC and gh-ost will at least have that in common. Until then there isn't anything we can do to address the limitations you bring up. |
@adregner Thanks. I am aware about gh-ost project. There are similar issues there: github/gh-ost#153, github/gh-ost#507. It seems both problems are solvable there. |
https://github.com/facebookincubator/OnlineSchemaChange/wiki/Limitation
Would it be possible to add support for tables with triggers and foreign keys? Almost all our tables have foreign keys as we use MySQL Innodb engine and some of the huge tables have triggers.
The text was updated successfully, but these errors were encountered: