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

v16: Online DDL: enforce ALGORITHM=COPY on shadow table #12522

Merged

Conversation

shlomi-noach
Copy link
Contributor

Description

Similarly to #12436, this PR uses explicit ALGORITHM=COPY when altering Online DDL shadow tables. The shadow table is empty anyway, so there is no performance impact to using COPY. The advantage of using COPY is that Xtrabackup (at least on some versions?) has problems backing up tables created with INSTANT algorithm.

Related Issue(s)

Fixes #12517

Checklist

  • "Backport to:" labels have been added if this change should be back-ported
  • Tests were added or are not required
  • Did the new or modified tests pass consistently locally and on the CI
  • Documentation was added or is not required

Deployment Notes

@vitess-bot
Copy link
Contributor

vitess-bot bot commented Feb 28, 2023

Review Checklist

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

General

  • Ensure that the Pull Request has a descriptive title.
  • If this is a change that users need to know about, please apply the release notes (needs details) label so that merging is blocked unless the summary release notes document is included.
  • If a test is added or modified, there should be a documentation on top of the test to explain what the expected behavior is what the test does.

If a new flag is being introduced:

  • Is it really necessary to add this flag?
  • Flag names should be clear and intuitive (as far as possible)
  • Help text should be descriptive.
  • Flag names should use dashes (-) as word separators rather than underscores (_).

If a workflow is added or modified:

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

Bug fixes

  • There should be at least one unit or end-to-end test.
  • The Pull Request description should include a link to an issue that describes the bug.

Non-trivial changes

  • There should be some code comments as to why things are implemented the way they are.

New/Existing features

  • Should be documented, either by modifying the existing documentation or creating new documentation.
  • New features should have a link to a feature request issue or an RFC that documents the use cases, corner cases and test cases.

Backward compatibility

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

@vitess-bot vitess-bot bot added NeedsDescriptionUpdate The description is not clear or comprehensive enough, and needs work NeedsWebsiteDocsUpdate What it says labels Feb 28, 2023
@shlomi-noach shlomi-noach requested a review from deepthi February 28, 2023 20:27
Signed-off-by: Shlomi Noach <[email protected]>
@@ -1175,7 +1178,7 @@ func (e *Executor) validateAndEditAlterTableStatement(ctx context.Context, onlin
// in the same statement
extraAlterTable := &sqlparser.AlterTable{
Table: alterTable.Table,
AlterOptions: []sqlparser.AlterOption{opt},
AlterOptions: []sqlparser.AlterOption{opt, sqlparser.AlgorithmValue("COPY")},
Copy link
Member

Choose a reason for hiding this comment

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

Is it worth declaring the algorithm values as constants versus hard-coded strings?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Made as constants in sql.y and sqlparser level

@deepthi deepthi added Backport to: release-15.0 and removed NeedsDescriptionUpdate The description is not clear or comprehensive enough, and needs work NeedsWebsiteDocsUpdate What it says labels Feb 28, 2023
@deepthi
Copy link
Member

deepthi commented Feb 28, 2023

I added a backport label, but it seems to me that this is really only a problem with v16 (or rather, the use of a newer MySQL version). We know that v15.0.2 + MySQL 8.0.23 does not suffer from this issue, so we probably don't need to backport this to v15 after all.

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

Per https://docs.percona.com/percona-xtrabackup/8.0/em/instant.html, the issue is resolved in MySQL 8.0.32 + Percona xtrabackup 8.0.32.

Copy from said doc:

To find tables with INSTANT ADD/DROP COLUMNS run the following command:

mysql> SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLES WHERE TOTAL_ROW_VERSIONS > 0;
+---------+
| NAME    |
+---------+
| test/t1 |
| test/t2 |
| test/t3 |
+---------+
3 rows in set (0.02 sec)

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

The unit tests are failing, over an obvious change in this PR (upper vs. lower case 'COPY), but I'm unable to find where the test happens!

2023-03-01T07:50:34.0530040Z === RUN   TestAlterTableAlgorithm
2023-03-01T07:50:34.0530208Z === RUN   TestAlterTableAlgorithm/add_column
2023-03-01T07:50:34.0530360Z     sidecardb_test.go:185: 
2023-03-01T07:50:34.0530856Z         	Error Trace:	/home/runner/work/vitess/vitess/go/vt/sidecardb/sidecardb_test.go:185
2023-03-01T07:50:34.0531101Z         	Error:      	Not equal: 
2023-03-01T07:50:34.0531382Z         	            	expected: "COPY"
2023-03-01T07:50:34.0531713Z         	            	actual  : "copy"
2023-03-01T07:50:34.0531880Z         	            	
2023-03-01T07:50:34.0532064Z         	            	Diff:
2023-03-01T07:50:34.0532389Z         	            	--- Expected
2023-03-01T07:50:34.0532682Z         	            	+++ Actual
2023-03-01T07:50:34.0532993Z         	            	@@ -1,2 +1,2 @@
2023-03-01T07:50:34.0533582Z         	            	-(sqlparser.AlgorithmValue) (len=4) "COPY"
2023-03-01T07:50:34.0534095Z         	            	+(sqlparser.AlgorithmValue) (len=4) "copy"
2023-03-01T07:50:34.0534333Z         	            	 
2023-03-01T07:50:34.0534714Z         	Test:       	TestAlterTableAlgorithm/add_column
2023-03-01T07:50:34.0534934Z === RUN   TestAlterTableAlgorithm/modify_column
2023-03-01T07:50:34.0535099Z     sidecardb_test.go:185: 
2023-03-01T07:50:34.0535549Z         	Error Trace:	/home/runner/work/vitess/vitess/go/vt/sidecardb/sidecardb_test.go:185
2023-03-01T07:50:34.0535710Z         	Error:      	Not equal: 
2023-03-01T07:50:34.0536046Z         	            	expected: "COPY"
2023-03-01T07:50:34.0536356Z         	            	actual  : "copy"
2023-03-01T07:50:34.0536582Z         	            	
2023-03-01T07:50:34.0536779Z         	            	Diff:
2023-03-01T07:50:34.0537119Z         	            	--- Expected
2023-03-01T07:50:34.0537357Z         	            	+++ Actual
2023-03-01T07:50:34.0537726Z         	            	@@ -1,2 +1,2 @@
2023-03-01T07:50:34.0538295Z         	            	-(sqlparser.AlgorithmValue) (len=4) "COPY"
2023-03-01T07:50:34.0538794Z         	            	+(sqlparser.AlgorithmValue) (len=4) "copy"
2023-03-01T07:50:34.0539024Z         	            	 
2023-03-01T07:50:34.0539315Z         	Test:       	TestAlterTableAlgorithm/modify_column
2023-03-01T07:50:34.0539573Z --- FAIL: TestAlterTableAlgorithm (0.00s)
2023-03-01T07:50:34.0539869Z     --- FAIL: TestAlterTableAlgorithm/add_column (0.00s)
2023-03-01T07:50:34.0540222Z     --- FAIL: TestAlterTableAlgorithm/modify_column (0.00s)

There is no such test TestAlterTableAlgorithm and so I believe it's auto generated. There is no such line sidecardb_test.go:185 - the file is shorter. I can't find where and how this test comes to be... 😱

@shlomi-noach
Copy link
Contributor Author

Was working with a repo that was behind vitessio/vitess. I can reproduce the tests locally now.

Signed-off-by: Shlomi Noach <[email protected]>
Copy link
Member

@frouioui frouioui left a comment

Choose a reason for hiding this comment

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

I think we should document this fix and the issue (#12517) as a known issue in the 16_0_0_[summary|release_notes].md files. However, this can be done in a follow-up PR in order to not overload the CI, changes to the .md files won't trigger the CI if done in a subsequent PR.

This looks good to me from my limited onlineddl knowledge point of view.

@shlomi-noach
Copy link
Contributor Author

Release notes updated by @GuptaManan100 in #12536

@shlomi-noach shlomi-noach merged commit 7666f16 into vitessio:release-16.0 Mar 2, 2023
@shlomi-noach shlomi-noach deleted the online-ddl-algorithm-copy-v16 branch March 2, 2023 13:17
@hmaurer hmaurer mentioned this pull request Mar 21, 2024
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