-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Enable Online DDL foreign key support (also in vtgate stress tests) when backing MySQL includes appropriate patch #14370
Enable Online DDL foreign key support (also in vtgate stress tests) when backing MySQL includes appropriate patch #14370
Conversation
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
- Check for 'rename_table_preserve_foreign_key' variable - Concurrency based on num CPUs - additional tests: add FK, drop FK Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
…hen appropriate Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Review ChecklistHello reviewers! 👋 Please follow this checklist when reviewing this Pull Request. General
Tests
Documentation
New flags
If a workflow is added or modified:
Backward compatibility
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great!
fixed |
…n_key' Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Description
As explained in https://vitess.io/blog/2021-06-15-online-ddl-why-no-fk/, Online DDL cannot work with vanilla MySQL.
However, this patch, as part of this public fork, modifies MySQL as follows:
rename_table_preserve_foreign_key
global/session boolean variable (defaults false/0 for backwards compatibility).RENAME TABLES
statement that replaces two tables Online-DDL-style, pins any children tables' foreign keys to the table name rather than the table pointer. Meaning after theRENAME
, the children point to the new table that is using the original table name, rather than migrating along with the old table. This supports Online DDL for parent tables.FOREIGN_KEY_CHECKS=0
for those specific tables. This supports Online DDL for children tables.In this PR:
rename_table_preserve_foreign_key
variable. If present, that means Online DDLALTER TABLE
is possible invitess
strategy.rename_table_preserve_foreign_key
to1
for the cut-over process (MySQL needs to prove it supports the variable at the beginning and at the end of a migration).rename_table_preserve_foreign_key
.Note that https://github.com/vitessio/vitess uses vanilla MySQL in its CI workflows. Therefore, the changes made to the endtoend tests in this PR won't actually run in GitHub CI for this repo. The changes are stress tested (as part of any pull request) inside PlanetScale (developers of this patch) using aforementioned MySQL patch.
As a reminder, one still must use
--unsafe-allow-foreign-keys
DDL strategy when affected tables participate in FK constraint relationship.Related Issue(s)
Checklist
Deployment Notes