-
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
: formalize InstantDDLCapability
#14900
schemadiff
: formalize InstantDDLCapability
#14900
Conversation
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
…ff is capable of INSTANT algorithm 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>
…ntDDL instead Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
…it. Introduce mysql.ServerVersionCapableOf() helper function 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>
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
|
schemadiff
: formalize InstantDDLCapability
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Now that #14883 is merged, this PR is ready to review. |
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.
LGTM! Only had minor questions that you can handle as you feel is best.
go/vt/schemadiff/schema.go
Outdated
@@ -23,6 +23,7 @@ import ( | |||
"sort" | |||
"strings" | |||
|
|||
"vitess.io/vitess/go/mysql" |
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.
Not directly related but I thought that the other capabilities package refactor was meant to avoid having to import the mysql package in schemadiff. No? Perhaps I'm misremembering.
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.
Oh that's true! Good catch.
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.
Going to refactor go/mysql
a bit, it will be better for everyone in the end. Will comment again once done for another review.
go/vt/schemadiff/schema_diff.go
Outdated
// The general logic: we return "InstantDDLCapabilityPossible" if there is one or more diffs that is capable of | ||
// ALGORITHM=INSTANT, and zero or more diffs that are irrelevant. |
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.
Would it be simpler and more clear to say that we return "InstantDDLCapabilityPossible" if there are no diffs which are impossible to run with ALGORITHM=INSTANT? They're both saying the same thing, AFAICT, but it feels easier to parse. I think it's also more precise because you could have:
if there is one or more diffs that is capable of
// ALGORITHM=INSTANT, and zero or more diffs that are irrelevant.`
But ALSO have one more more that are impossible. No? It's obviously minor.
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.
Would it be simpler and more clear to say that we return "InstantDDLCapabilityPossible" if there are no diffs which are impossible to run with ALGORITHM=INSTANT?
The distinction we're trying to make is between "there's nothing relevant to INSTANT" and "there's nothing to prevent an INSTANT".
Example to the first would be a change with only a bunch of CREATE
and DROP
statements. None of them are "impossible" for INSTANT
, but they're all just irrelevant. For this diff, you can technically say it's eligigle for INSTANT, but that's also misleading. There would be nothing to do. You cannot improve, change, or hasten the migrations in any way.
Example to the second is a bunch of CREATE
and DROP
, and one ALTER TABLE ... ADD COLUMN
. Here, as a whole, we say that it's possible to run INSTANT DDL. There is an actual different course of action to the diff as a whole, if we apply ALGORITHM=INSTANT.
The distinction is really important, because we want to be able to look at a diff and say "hey, if you want this diff to run faster, you could add ALGORITHM=INSTANT". This kind of suggestion would be misleading in the 1st example, and beneficial in the 2nd example.
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.
But ALSO have one more more that are impossible. No? It's obviously minor.
Yes, clarified in code comment.
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>
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #14900 +/- ##
==========================================
+ Coverage 47.28% 47.29% +0.01%
==========================================
Files 1138 1139 +1
Lines 238842 238845 +3
==========================================
+ Hits 112925 112972 +47
+ Misses 117326 117282 -44
Partials 8591 8591 ☔ View full report in Codecov by Sentry. |
Gonna merge this shortly so I can start using the new functionality. |
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Description
Another followup and iteration on #14878.
The changes in this PR are not (yet) put to use, so this PR does not modify any existing behavior.
In this PR we formalize further what it means for a single diff, or for a group of diffs, to be
INSTANT
-capable.EntityDiff
interface now hasInstantDDLCapability() InstantDDLCapability
function.For most diffs, like
CREATE TABLE
,ALTER VIEW
, etc., the capability isInstantDDLCapabilityIrrelevant
. That's because you can't applyALGORITHM=INSTANT
on such diff. ForAlterTableEntityDiff
, which stands forALTER TABLE
, the capability would be eitherInstantDDLCapabilityUnknown
(more on this shortly),InstantDDLCapabilityImpossible
(e.g. onADD FOREIGN KEY
) orInstantDDLCapabilityPossible
(e.g. onADD COLUMN
).MySQLServerVersion
inDiffHints
. Without this information, we do not know whatINSTANT
capabilities the diff has. And therefore without this info the capability isInstantDDLCapabilityUnknown
.SchemaDiff()
function, that computes aSchemaDiff
object, computes and populates relevantInstantDDLCapability
in anyAlterTableEntityDiff
.func (d *SchemaDiff) InstantDDLCapability() InstantDDLCapability
tells us what the overallINSTANT
-capability is for a multi-change.We remove
CapableOfInstantDDL()
function (unused) which only returned abool
value, which wasn't informative enough.Related Issue(s)
INSTANT
-capable changes #14877flavor
code. #14883Checklist
Deployment Notes