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

Support for ALTER VITESS_MIGRATION statements #7663

Merged

Conversation

shlomi-noach
Copy link
Contributor

Description

This PR introduces the following queries:

  • ALTER VITESS_MIGRATION '8c096d5e_81c0_11eb_a8d2_f875a4d24e90' RETRY
  • ALTER VITESS_MIGRATION '8c096d5e_81c0_11eb_a8d2_f875a4d24e90' CANCEL
  • ALTER VITESS_MIGRATION CANCEL ALL

The above map to these vtctl commands, respectively:

  • vtctl OnlineDDL <keyspace> retry 8c096d5e_81c0_11eb_a8d2_f875a4d24e90
  • vtctl OnlineDDL <keyspace> cancel 8c096d5e_81c0_11eb_a8d2_f875a4d24e90
  • vtctl OnlineDDL <keyspace> cancel all

Also, reserved but not implemented yet:

  • ALTER VITESS_MIGRATION '8c096d5e_81c0_11eb_a8d2_f875a4d24e90' COMPLETE

Returned result set for these queries is always empty, but AffectedRows indicates how many migrations were actually affected by the command.

The various endtoend/onlineddl tests now use these queries.

Related Issue(s)

Checklist

  • Should this PR be backported?
  • Tests were added or are not required
  • Documentation was added or is not required

Deployment Notes

Impacted Areas in Vitess

Components that this PR will affect:

  • Query Serving
  • VReplication
  • Cluster Management
  • Build/CI
  • VTAdmin

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>
…or RETRY alter type

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>
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>
@shlomi-noach
Copy link
Contributor Author

This PR extends #7656 ; it makes sense to review this PR after #7656 is merged.

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

Documentation to follow

@shlomi-noach
Copy link
Contributor Author

This PR also refactors endtoend/onlineddl tests by consolidating much of the shared logic and refactoring functions into endtoend/onlineddl/vtgate_utils.go

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
Copy link
Contributor Author

@systay points out that this PR has commits from merged PRs. It seems to be a rebase gone wrong. However, code-wise and diff-wise there doesn't seem to be a risk here.

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
Copy link
Contributor Author

Confused about endtoend / End-to-End Test failures, e.g.: https://github.com/vitessio/vitess/pull/7663/checks?check_run_id=2105797750

They're consistently failing after 5m. It seems like a timeout issue. But I can't find what times out after 5m. The test itself (https://github.com/vitessio/vitess/blob/master/.github/workflows/endtoend.yml) is set with timeout-minutes: 30

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
Copy link
Contributor Author

Kind request for review 🙏 (reminder: this PR extends #7656)

shlomi-noach and others added 2 commits March 16, 2021 09:40
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
The old test had hardcoded values for the expected sizes of internal
data structures. This makes for very brittle tests whenever we change
the AST or introduce new query types. Instead of checking for the exact
sizes of the data structures, check that they're being stored and
whether they're larger than than an empty plan.

Signed-off-by: Vicent Marti <vmg@strn.cat>
@shlomi-noach
Copy link
Contributor Author

will resolve conflicts after #7656 is merged. The conflicts are due to #7669. See d0c741f for how conflict was resolved in #7656

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
Copy link
Contributor Author

Sheesh. GitHub Actions is having another bad day.

Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
vtrpcpb "vitess.io/vitess/go/vt/proto/vtrpc"
"vitess.io/vitess/go/vt/sqlparser"
"vitess.io/vitess/go/vt/vterrors"
"vitess.io/vitess/go/vt/vtgate/engine"
)

func buildRevertPlan(query string, stmt *sqlparser.RevertMigration, vschema ContextVSchema) (engine.Primitive, error) {
func buildAlterMigrationPlan(query string, stmt *sqlparser.AlterMigration, vschema ContextVSchema) (engine.Primitive, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: why ask for stmt and then not use it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nice catch! Removed.

e.migrationMutex.Lock()
defer e.migrationMutex.Unlock()
parsed := sqlparser.BuildParsedQuery(sqlRetryMigration, ":tablet", whereExpr)
parsed := sqlparser.BuildParsedQuery(sqlRetryMigrationWhere, ":tablet", whereExpr)
Copy link
Collaborator

Choose a reason for hiding this comment

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

just noticed that three lines down, on line 2247, we are never checking err from parsed.GenerateQuery

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!

shlomi-noach and others added 2 commits March 17, 2021 17:12
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
…terface-alter

Signed-off-by: Andres Taylor <andres@planetscale.com>
Copy link
Collaborator

@systay systay left a comment

Choose a reason for hiding this comment

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

LGTM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants