Skip to content
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: better support for range partitioning #15698

Merged
merged 18 commits into from May 1, 2024

Conversation

shlomi-noach
Copy link
Contributor

Description

Context: #15674. This PR improves Online DDL support for range partitioning as follows:

  • Deprecating --fast-range-rotation DDL strategy. The flag is still allowed, but always assumed to be true. As discussed in Tracking: Online DDL partitioning changes improved support #15674 , a range partition rotation statement should always execute directly, and not through Online DDL.
  • schemadiff takes ownership of range partitioning rotation analysis, instead of onlineddl/analysis.go.
  • ALTER TABLE ... DROP PARTITION supports multiple partition names. schemadiff now generates a single ALTER TABLE with all dropped partitions rather than splitting into multiple ALTER TABLE statements.
  • Previously, we only considered these range partition rotation scenarios: dropping 1 or more partitions from the prefix, or adding 1 partition as the suffix of the range. Now, we also allow dropping of any partition from the range (as this operation is fully allowed in MySQL).
  • Previously, with --fast-range-rotation and assuming a range partition rotation, Online DDL devised designated plans for "add-range-partition" and for "drop-range-partition", decorated with metadata, and presented some logic for potential revertibility of some operations. After consideration, we remove this logic. We cannot achieve revertibility for the entire set of partition rotation scenarios, and we choose to not offer revertibility for any of them, just as we don't offer revertibility for instant-ddl.

Related Issue(s)

#15674

Checklist

  • "Backport to:" labels have been added if this change should be back-ported to release branches
  • If this change is to be back-ported to previous releases, a justification is included in the PR description
  • Tests were added or are not required
  • Did the new or modified tests pass consistently locally and on CI?
  • Documentation was added or is not required

Deployment Notes

…(applies to same table)

Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
…s always 'true'

Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
…ways be true

Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
…nts, to allow multi-table DROP PARTITION statements

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>
…tements combine DROP PARTITION statements

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>
…o, it does not mark any particular details about a partition rotation special operation, as we do not expect such an operation to be revertible

Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
@shlomi-noach shlomi-noach added Type: Internal Cleanup Type: Enhancement Logical improvement (somewhere between a bug and feature) Component: Online DDL Online DDL (vitess/native/gh-ost/pt-osc) labels Apr 11, 2024
Copy link
Contributor

vitess-bot bot commented Apr 11, 2024

Review Checklist

Hello reviewers! 👋 Please follow this checklist when reviewing this Pull Request.

General

  • Ensure that the Pull Request has a descriptive title.
  • Ensure there is a link to an issue (except for internal cleanup and flaky test fixes), new features should have an RFC that documents use cases and test cases.

Tests

  • Bug fixes should have at least one unit or end-to-end test, enhancement and new features should have a sufficient number of tests.

Documentation

  • Apply the release notes (needs details) label if users need to know about this change.
  • New features should be documented.
  • There should be some code comments as to why things are implemented the way they are.
  • There should be a comment at the top of each new or modified test to explain what the test does.

New flags

  • Is this flag really necessary?
  • Flag names must be clear and intuitive, use dashes (-), and have a clear help text.

If a workflow is added or modified:

  • Each item in Jobs should be named in order to mark it as required.
  • If the workflow needs to be marked as required, the maintainer team must be notified.

Backward compatibility

  • Protobuf changes should be wire-compatible.
  • Changes to _vt tables and RPCs need to be backward compatible.
  • RPC changes should be compatible with vitess-operator
  • If a flag is removed, then it should also be removed from vitess-operator and arewefastyet, if used there.
  • vtctl command output order should be stable and awk-able.

@vitess-bot 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 Apr 11, 2024
@shlomi-noach shlomi-noach requested a review from a team April 11, 2024 10:50
@github-actions github-actions bot added this to the v20.0.0 milestone Apr 11, 2024
@shlomi-noach shlomi-noach 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 Apr 11, 2024
Copy link

codecov bot commented Apr 11, 2024

Codecov Report

Attention: Patch coverage is 69.23077% with 16 lines in your changes are missing coverage. Please review.

Project coverage is 68.45%. Comparing base (cf3acaa) to head (c0b7a45).
Report is 2 commits behind head on main.

Files Patch % Lines
go/vt/schemadiff/analysis.go 65.38% 9 Missing ⚠️
go/vt/vttablet/onlineddl/analysis.go 0.00% 3 Missing ⚠️
go/vt/schemadiff/errors.go 0.00% 2 Missing ⚠️
go/vt/schema/ddl_strategy.go 50.00% 1 Missing ⚠️
go/vt/vttablet/onlineddl/executor.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #15698      +/-   ##
==========================================
+ Coverage   68.41%   68.45%   +0.04%     
==========================================
  Files        1558     1559       +1     
  Lines      196353   196302      -51     
==========================================
+ Hits       134337   134388      +51     
+ Misses      62016    61914     -102     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -209,7 +209,7 @@ func (setting *DDLStrategySetting) IsPreferInstantDDL() bool {

// IsFastRangeRotationFlag checks if strategy options include --fast-range-rotation
func (setting *DDLStrategySetting) IsFastRangeRotationFlag() bool {
return setting.hasFlag(fastRangeRotationFlag)
return true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to clean up this function in a follow up PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function is now removed.

Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
@shlomi-noach
Copy link
Contributor Author

Ping for review 🙏


import "vitess.io/vitess/go/vt/sqlparser"

// AlterTableRotatesRangePartition answers `true` when the given ALTER TABLE statemnts performas any sort
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Obviously minor, but statemnts performas -> statement performs

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

if onlineDDL.StrategySetting().IsFastRangeRotationFlag() {
op, err := analyzeDropRangePartition(alterTable, createTable)
//
// - nothing here thus far
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we saying that there are no special plans which support reverts?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At this point in time yes. If we happen to stumble on some special plan that is revertible -- that's great.

// Such would be:
// - Dropping any partition(s)
// - Adding a new partition (empty, at the end of the list)
func AlterTableRotatesRangePartition(alterTable *sqlparser.AlterTable) (bool, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we discussed via Slack, I think that we should at least check that this is indeed a RANGE partition change (vs. e.g. LIST).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

…ount and validates the table has RANGE partitioning

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>
@shlomi-noach shlomi-noach merged commit 1c4cd97 into vitessio:main May 1, 2024
104 checks passed
@shlomi-noach shlomi-noach deleted the schemadiff-partition-changes branch May 1, 2024 05:10
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) Type: Enhancement Logical improvement (somewhere between a bug and feature) Type: Internal Cleanup
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants