-
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
Online DDL: fast (and correct) RANGE PARTITION operations, 1st iteration #10315
Online DDL: fast (and correct) RANGE PARTITION operations, 1st iteration #10315
Conversation
Signed-off-by: Shlomi Noach <[email protected]>
Signed-off-by: Shlomi Noach <[email protected]>
Signed-off-by: Shlomi Noach <[email protected]>
Signed-off-by: Shlomi Noach <[email protected]>
Signed-off-by: Shlomi Noach <[email protected]>
Signed-off-by: Shlomi Noach <[email protected]>
…olumn including full partition spec Signed-off-by: Shlomi Noach <[email protected]>
Signed-off-by: Shlomi Noach <[email protected]>
Review ChecklistHello reviewers! 👋 Please follow this checklist when reviewing this Pull Request. General
Bug fixes
Non-trivial changes
New/Existing features
Backward compatibility
|
go/vt/schema/ddl_strategy.go
Outdated
@@ -150,6 +151,11 @@ func (setting *DDLStrategySetting) IsAllowConcurrent() bool { | |||
return setting.hasFlag(allowConcurrentFlag) | |||
} | |||
|
|||
// IsFastOverRevertibleFlag checks if strategy options include -fast-ver-revertible |
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.
fast-ver-revertible
-> fast-over-revertible
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.
fixed
go/vt/vttablet/onlineddl/analysis.go
Outdated
} | ||
|
||
// analyzeDropFirstOrLastRangePartition sees if the online DDL drops the first or last partition | ||
// in a range partitioned table |
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.
Isn't this only checking if it's the first partition?
And isn't adding checking if it's adding the last? So is this comment here correct?
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.
fixed. The code was refactored into a more general form, and the original comment was left behind.
go/vt/vttablet/onlineddl/analysis.go
Outdated
} | ||
|
||
// analyzeDropFirstOrLastRangePartition sees if the online DDL drops the first or last partition | ||
// in a range partitioned table |
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, I think the comment is wrong.
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.
fixed
go/vt/vttablet/onlineddl/analysis.go
Outdated
partitionName := partitionDefinition.Name.String() | ||
// OK then! | ||
|
||
// Now, is this query adding a parititon in a RANGE partitioned table? |
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.
parititon
-> partition
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.
fixed
|
||
// analyzeSpecialAlterScenarios checks if the given ALTER onlineDDL, and for the current state of affected table, | ||
// can be executed in a special way | ||
func (e *Executor) analyzeSpecialAlterPlan(ctx context.Context, onlineDDL *schema.OnlineDDL) (*SpecialAlterPlan, error) { |
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.
Comment is wrong for the function name here.
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.
fixed
Signed-off-by: Shlomi Noach <[email protected]>
Ugh edited online and that lost the signature. Gonna force-push shortly. |
Signed-off-by: Shlomi Noach <[email protected]>
d6de80c
to
e535497
Compare
Related, design proposal: #10317 This PR implements the forward migration aspect. |
This was a thing I had most questions over reading the code, but I think this makes sense. My concern was mostly on whether it's needed to control revertible or not strategies at a finer level or not, say, wanting to use it for partitions but not for an But if this flag becomes eventually irrelevant for partitions, I think most of that concern disappears. That's also because partitions seem to be quite a different beast in general but with a separate strategy for dealing with them as discussed in #10317 I think we're ok. So tl;dr, I think that if we would keep partitions as is without #10317, we would want to have a separate flag to control partitions vs. other fast over revertible cases, but given #10317 I don't think we need that (so one flag is better then I think). |
My thought as well, these probably deserve different flags. Let's see how we make progress. |
go/vt/vttablet/onlineddl/analysis.go
Outdated
partitionName := spec.Names[0].String() | ||
// OK then! | ||
|
||
// Now, is this query dropping the first parititon in a RANGE partitioned table? |
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.
parititon
-> partition
.
Signed-off-by: Shlomi Noach <[email protected]>
Signed-off-by: Shlomi Noach <[email protected]>
Signed-off-by: Shlomi Noach <[email protected]>
Out of caution, added a new
Both flags remain undocumented. |
Signed-off-by: Shlomi Noach <[email protected]>
Signed-off-by: Shlomi Noach <[email protected]>
Signed-off-by: Shlomi Noach <[email protected]>
Signed-off-by: Shlomi Noach <[email protected]>
Ping for review from the Vitess team |
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
Description
This PR introduces support for fast
ADD PARTITION
andDROP PARTITION
inRANGE
partitioned tables. At this time these fast migrations are not revertible, but a future iteration will make them revertible.Why, what's the problem with existing implementation?
For both speed and correctness.
vitess
migrations, handles this incorrectly. When youDROP PARTITION
in an online schema change tool, the tool creates a shadow table with that partition removed. It then copies over all table rows from the original table. What used to be the 2nd partition (now the first after dropping the oldest partition) turns out to be a good host for all the old partition's rows. The end result is that no rows are deleted in the process. Which not what the user wanted.How
Confronted with an
ALTER TABLE
statement, and before sending it over to the appropriate handler (vitess
,gh-ost
,pt-osc
), the executor checks if it can execute the migration using a "special plan". By parsing and analyzing the exact semantics of the query,vitess
is able to know a statement is aADD|DROP
of aRANGE PARTITION
; and if that is the case, it executes the query directly on the backend MySQL server, rather then invoke an OSC.Limitations
ALTER TABLE ... DROP PARTITION
may only drop one partition at a time (the MySQL syntax allows dropping multiple partitions at once).--fast-over-revertible
--fast-range-rotation
flag inddl_strategy
. This flag will be useful to additional migration types, but we expect it to eventually be irrelevant toADD|DROP PARTITION
queries, as we do intend to make them revertible.There are no release notes in the meantime as I want to see how next iterations make progress. No documentation for this new behavior yet until we consider it stable.
Related Issue(s)
Checklist
Deployment Notes