-
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
schemadiff
: improved diff ordering with various foreign key strategies
#16081
Merged
mattlord
merged 8 commits into
vitessio:main
from
planetscale:schemadiff-sequential-complex-refactor
Jun 10, 2024
Merged
schemadiff
: improved diff ordering with various foreign key strategies
#16081
mattlord
merged 8 commits into
vitessio:main
from
planetscale:schemadiff-sequential-complex-refactor
Jun 10, 2024
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>
…-desired search path, that first attempts to echieve a dependency resolution with strictest means, but if impossible, resotrs to more relaxed constraints 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
|
vitess-bot
bot
added
NeedsBackportReason
If backport labels have been applied to a PR, a justification is required
NeedsDescriptionUpdate
The description is not clear or comprehensive enough, and needs work
NeedsIssue
A linked issue is missing for this Pull Request
NeedsWebsiteDocsUpdate
What it says
labels
Jun 9, 2024
shlomi-noach
added
Type: Enhancement
Logical improvement (somewhere between a bug and feature)
Component: Query Serving
Component: Online DDL
Online DDL (vitess/native/gh-ost/pt-osc)
and removed
NeedsDescriptionUpdate
The description is not clear or comprehensive enough, and needs work
NeedsWebsiteDocsUpdate
What it says
NeedsIssue
A linked issue is missing for this Pull Request
NeedsBackportReason
If backport labels have been applied to a PR, a justification is required
labels
Jun 9, 2024
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #16081 +/- ##
==========================================
- Coverage 68.19% 68.19% -0.01%
==========================================
Files 1541 1541
Lines 197369 197391 +22
==========================================
+ Hits 134605 134618 +13
- Misses 62764 62773 +9 ☔ View full report in Codecov by Sentry. |
dbussink
approved these changes
Jun 10, 2024
mattlord
approved these changes
Jun 10, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Component: Online DDL
Online DDL (vitess/native/gh-ost/pt-osc)
Component: Query Serving
Type: Enhancement
Logical improvement (somewhere between a bug and feature)
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
We introduce a new foreign key diff strategy flag and improve the diff sorting mechanism. The strategy flags are now: (from strict to loose):
ForeignKeyCheckStrategyStrict
ForeignKeyCheckStrategyCreateTableFirst
ForeignKeyCheckStrategyIgnore
The main change in this PR is the understanding that "stricter is better, if possible". In this PR, if we request a diff using a loose
ForeignKeyCheckStrategyIgnore
strategy, and the diff can be fulfilled by the stricterForeignKeyCheckStrategyStrict
, then it will. If not, and can be fulfilled by still stricterForeignKeyCheckStrategyCreateTableFirst
, it will.The converse is not true: if we request a diff using
ForeignKeyCheckStrategyStrict
strategy, then it may only be fulfilled viaForeignKeyCheckStrategyStrict
.In effect, this is only relevant when cyclic foreign keys are introduced. When we say "cyclic", we refer to tables referencing each other such as
t1->t2->t3->t1
. This PR is not about existence of cyclic tables; it is about introducing a cyclic change such that the diff themselves might depend on each other. And the discussion is: "what is a valid order of diffs, such that we can introduce one diff at a time, maintain a valid schema, and end of with the desired schema"?It is not always possible to get such ordering given a set of changes, and the different strategies tell us how to tackle such situations:
ForeignKeyCheckStrategyStrict
: there absolutely must be a valid sequence, or else we return an error.ForeignKeyCheckStrategyCreateTableFirst
: it's possible to have an invalid sequence, but we tolerate a sequence where the first change isALTER TABLE
, even if it introduces a dependency which is not yet met. The rest of changes must then all line up. At the end of all changes, we must achieve a valid schema.ForeignKeyCheckStrategyIgnore
: we don't care at all if there's no valid sequence. But at the end of all changes, we must achieve a valid schema.Related Issue(s)
#15430
Checklist
Deployment Notes