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

OnlineDDL to use schemadiff version capabilities; refactor some flavor code. #14883

Merged

Conversation

shlomi-noach
Copy link
Contributor

@shlomi-noach shlomi-noach commented Jan 4, 2024

Description

Followup to #14878, which introduced schemadiff logic for detecting INSTANT-able changes. In this PR:

  • onlineddl/analysis.go uses said schemadiff analysis, removing its own overlapping logic.
  • Improves the convenience of getting and using a CapableOf function.
    • Now, all it takes is a server version, and you get a function. See mysql.ServerVersionCapableOf(version) convenience function. I've switched all code that gets a CapableOf to use this new accessor function.
    • Refactored flavor such that all flavors contain a versionString field. It is then used by their supportsCapability(...) implementations, rather than having a version string supplied externally as a function argument.

Note: none of the Online DDL tests changed in essence - the point of this refactor is to preserve behavior through new implementation. The existing tests have good coverage and if they pass that means the refactor is good.

Related Issue(s)

Closes #14877

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

Signed-off-by: Shlomi Noach <[email protected]>
…ff is capable of INSTANT algorithm

Signed-off-by: Shlomi Noach <[email protected]>
Signed-off-by: Shlomi Noach <[email protected]>
Signed-off-by: Shlomi Noach <[email protected]>
…it. Introduce mysql.ServerVersionCapableOf() helper function

Signed-off-by: Shlomi Noach <[email protected]>
Signed-off-by: Shlomi Noach <[email protected]>
@shlomi-noach shlomi-noach added Type: Enhancement Logical improvement (somewhere between a bug and feature) Component: Online DDL Online DDL (vitess/native/gh-ost/pt-osc) labels Jan 4, 2024
Copy link
Contributor

vitess-bot bot commented Jan 4, 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 Jan 4, 2024
@github-actions github-actions bot added this to the v19.0.0 milestone Jan 4, 2024
@shlomi-noach shlomi-noach changed the title Onlineddl schemadiff capabilities OnlineDDL: use schemadiff capabilities, refactor some flavor code. Jan 4, 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 Jan 4, 2024
@shlomi-noach shlomi-noach changed the title OnlineDDL: use schemadiff capabilities, refactor some flavor code. OnlineDDL to use schemadiff version capabilities; refactor some flavor code. Jan 4, 2024
@shlomi-noach shlomi-noach requested a review from a team January 4, 2024 07:27
Copy link
Contributor

@mattlord mattlord left a comment

Choose a reason for hiding this comment

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

LGTM! I just had the minor questions/comments/suggestions. I'll leave it to you to resolve as you feel is best.

@@ -136,7 +136,7 @@ type flavor interface {
baseShowTables() string
baseShowTablesWithSizes() string

supportsCapability(serverVersion string, capability capabilities.FlavorCapability) (bool, error)
supportsCapability(capability capabilities.FlavorCapability) (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.

This now assumes that the serverVersion was specified otherwise. That's fine, I think, but we should probably add some error handling / unit test code covering the case where it's not set.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added unit test as suggested. In actual connections, serverVersion is always non-empty; the existing logic for setting a connection's flavor is to return nil flavor when there is no known flavor for the given server version (whether server version is empty, or something ridiculous as "1792.3343.3"). Just pointing out that on this respect there's nothing new this PR adds.

@@ -400,7 +402,8 @@ func (mysqlFlavor80) baseShowTablesWithSizes() string {
}

// supportsCapability is part of the Flavor interface.
func (mysqlFlavor80) supportsCapability(serverVersion string, capability capabilities.FlavorCapability) (bool, error) {
func (f mysqlFlavor80) supportsCapability(capability capabilities.FlavorCapability) (bool, error) {
serverVersion := f.serverVersion
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm guessing that if f.serverVersion is the zeroval, then this will just always return false, nil., which seems fine to me. We should add a unit test case for that though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added.

@@ -187,25 +194,29 @@ func GetFlavor(serverVersion string, flavorFunc func() flavor) (f flavor, capabl
f = flavorFunc()
case strings.HasPrefix(serverVersion, mariaDBReplicationHackPrefix):
canonicalVersion = serverVersion[len(mariaDBReplicationHackPrefix):]
f = mariadbFlavor101{}
f = mariadbFlavor101{mariadbFlavor{serverVersion: canonicalVersion}}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should have test coverage for what the expected behavior is if there's a future use of the flavor as we did before, i.e. with no serverVersion specified like it was here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added.

version: "8.0.20-log",
capability: capabilities.CheckConstraintsCapability,
isCapable: true,
},
Copy link
Contributor

Choose a reason for hiding this comment

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

Here, I think we could just add:

		{
			version:    "",
			capability: capabilities.CheckConstraintsCapability,
			isCapable:  false,
		},

No?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added.

Signed-off-by: Shlomi Noach <[email protected]>
Signed-off-by: Shlomi Noach <[email protected]>
@shlomi-noach
Copy link
Contributor Author

There will actually be a followup PR, I just don't want to overload this PR. I'm unhappy with the amount of information returned by CapableOfInstantDDL(). It only returns a bool, without indicating which migrations were at all eligible for INSTANT, or, which migrations were impossible for INSTANT (e.g. ALTER TABLE ... ADD INDEX), or, which migrations were impartial/irrelevant to INSTANT (e.g. a CREATE TABLE).

@shlomi-noach shlomi-noach requested a review from a team January 8, 2024 06:04
@shlomi-noach
Copy link
Contributor Author

Followup PR in #14900, will only be taken out of Draft when this PR is merged.

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)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature request: schemadiff to be aware and knowledgeable about INSTANT-capable changes
3 participants