-
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
Materializer: normalize schema via schemadiff on --atomic-copy #14636
Materializer: normalize schema via schemadiff on --atomic-copy #14636
Conversation
Signed-off-by: Shlomi Noach <[email protected]>
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
|
@@ -88,7 +88,7 @@ func TestFKWorkflow(t *testing.T) { | |||
} | |||
targetKeyspace := "fktarget" | |||
targetTabletId := 200 | |||
vc.AddKeyspace(t, []*Cell{cell}, targetKeyspace, shardName, initialFKTargetVSchema, initialFKSchema, 0, 0, targetTabletId, sourceKsOpts) | |||
vc.AddKeyspace(t, []*Cell{cell}, targetKeyspace, shardName, initialFKTargetVSchema, "", 0, 0, targetTabletId, sourceKsOpts) |
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 change to the test ensures the new behavior is applied. The schema in the test is composed of parent
and child
tables. Since child < parent
lexicographically, the test fails without the new normalization.
go/vt/vtctl/workflow/materializer.go
Outdated
log.Error(vterrors.Wrapf(err, "AtomicCopy: failed to normalize schema via schemadiff")) | ||
} else { | ||
applyDDLs = schema.ToQueries() | ||
log.Infof("AtomicCopy used, and schema was normalized via schemadiff. New queries: %v", applyDDLs) |
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.
Do we really want to always log this? As it can be a giant schema and thus a huge log entry?
go/vt/vtctl/workflow/materializer.go
Outdated
sql := strings.Join(applyDDLs, ";\n") | ||
log.Infof("materializer.deploySchema: sql=%v", sql) |
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.
Same here, this can be very big and also would duplicate the logging.
Signed-off-by: Shlomi Noach <[email protected]>
Description
In materializer, and right now scoped to
AtomicCopy
operations only (just to keep the blast radius smaller for the time being), we normalize the source schema viaschemadiff
where possible. This ensures ordering of tables is compliant with any foreign key constraints. See #14635 for details.Related Issue(s)
Fixes #14635
Checklist
Deployment Notes