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

Point in time recovery and restore: assume (and validate) MySQL56 flavor in position arguments #15599

Merged
merged 6 commits into from
Apr 10, 2024

Conversation

shlomi-noach
Copy link
Contributor

Description

Incremental backup and point-in-time recoveries assume a MySQL 5.6 flavor GTID. To that effect, both now:

  • Do not require the "MySQL56/" prefix in position argument
  • Validate that with or without said "MySQL56/" prefix, the positiion must be in MySQL 5.6 GTID format

This PR consolidated the logic into a new DecodePositionMySQL56() function in go/mysql/replication. We retire DecodePositionDefaultFlavor() though we still keep the function as it may yet prove useful.

Added unit tests, and updated endtoend tests to use positions with/out "MySQL56/" prefix.

Related Issue(s)

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

@shlomi-noach shlomi-noach added Type: Internal Cleanup Type: Enhancement Logical improvement (somewhere between a bug and feature) Backport This is a backport labels Mar 31, 2024
@shlomi-noach shlomi-noach requested review from mattlord and a team March 31, 2024 07:18
Copy link
Contributor

vitess-bot bot commented Mar 31, 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.

Copy link

codecov bot commented Mar 31, 2024

Codecov Report

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

Project coverage is 68.08%. Comparing base (e5eb981) to head (043deca).
Report is 15 commits behind head on main.

Files Patch % Lines
go/mysql/replication/mysql56_gtid.go 93.75% 1 Missing ⚠️
go/vt/mysqlctl/builtinbackupengine.go 66.66% 1 Missing ⚠️
go/vt/vttablet/tabletmanager/restore.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #15599      +/-   ##
==========================================
+ Coverage   65.78%   68.08%   +2.30%     
==========================================
  Files        1561     1561              
  Lines      194838   195316     +478     
==========================================
+ Hits       128171   132981    +4810     
+ Misses      66667    62335    -4332     

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

@shlomi-noach shlomi-noach added Component: Backup and Restore and removed Backport This is a backport labels Mar 31, 2024
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 only had minor comments that you can address as you feel is best.

go/mysql/replication/mysql56_gtid.go Outdated Show resolved Hide resolved
if err != nil {
return nil, vterrors.Wrapf(err, "cannot decode position in incremental backup: %v", incrementalFromPos)
}
if !pos.MatchesFlavor(replication.Mysql56FlavorID) {
return nil, vterrors.Errorf(vtrpc.Code_FAILED_PRECONDITION, "incremental backup only supports MySQL GTID positions. Got: %v", incrementalFromPos)
Copy link
Contributor

Choose a reason for hiding this comment

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

IMO it would be nice to move this wording to the error above so that it's clear that we don't support other flavors.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is likewise an intentional design: we Wrapf an error, which happens to be ErrExpectMysql56Flavor, and which explicitly tells us "expected MySQL GTID position but found a different or invalid format". It would be redundant to add the same wording here.

Copy link
Contributor

Choose a reason for hiding this comment

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

Right, but we lose the wording which notes that MySQL format is the only one supported. That was my point. I guess it's implicit in this wording, so not a huge deal.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We don't lose the wording. The error above will have both cannot decode position in incremental backup: %v as well as "expected MySQL GTID position but found a different or invalid format, because it wraps one with another. Am I misunderstanding?

Signed-off-by: Shlomi Noach <[email protected]>
pos, gtidSet, err := DecodePositionMySQL56("MySQL56/16b1039f-22b6-11ed-b765-0a43f95f28a3:1-615")
assert.NoError(t, err)
assert.False(t, pos.IsZero())
assert.NotNil(t, gtidSet)
Copy link
Member

Choose a reason for hiding this comment

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

Isn't it worth asserting that the provided gtidSet is not being mangled in any way, and makes it here intact?

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

pos, gtidSet, err := DecodePositionMySQL56("16b1039f-22b6-11ed-b765-0a43f95f28a3:1-615")
assert.NoError(t, err)
assert.False(t, pos.IsZero())
assert.NotNil(t, gtidSet)
Copy link
Member

Choose a reason for hiding this comment

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

Similarly here, it will be more robust to assert on the actual result versus only asserting that it is not nil.

Copy link
Member

Choose a reason for hiding this comment

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

We do have a utils.MustMatch somewhere that can be used to check for equality of complex structs.

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. No need for utils.MustMatch, assert.Equal(...) implements deep check.

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

Looking for another review 🙏

@shlomi-noach shlomi-noach merged commit 9c59280 into vitessio:main Apr 10, 2024
103 checks passed
@shlomi-noach shlomi-noach deleted the pitr-mysql56-flavor-default branch April 10, 2024 09:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Backup and Restore 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.

Bug Report: Flavor is required in GTID position for incremental restore-to-position value
4 participants