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

Incremental backup: fix calculation of binlog files to use #13066

Merged
merged 5 commits into from
May 21, 2023

Conversation

shlomi-noach
Copy link
Contributor

@shlomi-noach shlomi-noach commented May 10, 2023

Description

Incremental backup logic introduced in #11097 (still undocumented) did not evaluate the correct list of binary logs when gtid_purged happened to be exactly the last full backup position. There are probably more scenarios affected by the bug.

This PR treats gtid_purged and the last known backup pos correctly. Tests added.

Incremental backup and Point in time recovery as introduced in #11097, are still undocumented.

Related Issue(s)

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 vitess-bot bot added NeedsDescriptionUpdate The description is not clear or comprehensive enough, and needs work NeedsWebsiteDocsUpdate What it says labels May 10, 2023
@vitess-bot
Copy link
Contributor

vitess-bot bot commented May 10, 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.

@github-actions github-actions bot added this to the v17.0.0 milestone May 10, 2023
@shlomi-noach shlomi-noach removed NeedsDescriptionUpdate The description is not clear or comprehensive enough, and needs work NeedsWebsiteDocsUpdate What it says labels May 10, 2023
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! Only had a few very minor nits/suggestions. I'll leave those up to you.

if unionPreviousGTIDs {
prevPos.GTIDSet = prevGTIDsUnion
if i == 0 {
return nil, "", "", vterrors.Errorf(vtrpc.Code_FAILED_PRECONDITION, "the very first binlog file %v has PreviousGTIDs %s that exceed given incremental backup pos. There are GTID entries that are missing and this backup cannot run", binlog, previousGTIDsPos)
Copy link
Contributor

Choose a reason for hiding this comment

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

Might be worth using the GTID_PURGED language/variable specifically to aid in debugging and bridging the MySQL<->Vitess concepts/pieces 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.

Reworded

go/vt/mysqlctl/binlogs_gtid.go Outdated Show resolved Hide resolved
if i == 0 {
return nil, "", "", vterrors.Errorf(vtrpc.Code_FAILED_PRECONDITION, "the very first binlog file %v has PreviousGTIDs %s that exceed given incremental backup pos. There are GTID entries that are missing and this backup cannot run", binlog, prevPos)
if backupFromGTIDSet.Contains(previousGTIDsPos.GTIDSet) {
// All previous binary logs are fully contained by backupPos. So definitely all binlogs _prior_ to
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's easier to reason about when explained as the current binary log being the oldest one available -- so all previous GTIDs have been purged and are no longer available.

},
backupPos: "16b1039f-22b6-11ed-b765-0a43f95f28a3:1-63",
gtidPurged: "16b1039f-22b6-11ed-b765-0a43f95f28a3:1-2",
expectError: "There are GTID entries that are missing",
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit, but [purged and] no longer available feels more accurate than missing.

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

@mattlord please see if rewording makes more sense. I find it really difficult to explain the constraints in proper English. Please feel free to edit.

@mattlord
Copy link
Contributor

@mattlord please see if rewording makes more sense. I find it really difficult to explain the constraints in proper English. Please feel free to edit.

@shlomi-noach LGTM! ❤️

Copy link
Member

@deepthi deepthi left a comment

Choose a reason for hiding this comment

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

Only nits on wording etc. The logic looks good to me.

go/vt/mysqlctl/binlogs_gtid.go Outdated Show resolved Hide resolved
return nil, "", "", vterrors.Errorf(vtrpc.Code_FAILED_PRECONDITION, "binary log %v with previous GTIDS %s neither contains requested GTID %s nor contains it. Backup cannot take place", binlog, prevPos.GTIDSet, lookFromGTIDSet)
if !prevGTIDsUnion.Union(purgedGTIDSet).Contains(backupFromGTIDSet) {
return nil, "", "", vterrors.Errorf(vtrpc.Code_FAILED_PRECONDITION,
"Mismatching GTID entries. Requested backup pos has entries not found in the binary logs, and binary logs have entries not found in the requested backup pos. Requested pos=%v, binlog pos=%v",
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 and binary logs or or binary logs?
In other words, does the check imply both conditions have occurred, or that at least one of them has occurred?
You could replace and with and/or.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's an and, as described. It's like a Venn diagram of two circles which overlap, but neither fully contains the other.

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 Neither fully contains the other to the message. I hope it clarifies.

@shlomi-noach shlomi-noach merged commit 2a69ceb into vitessio:main May 21, 2023
@shlomi-noach shlomi-noach deleted the backup-pitr-bug-first-binlog branch May 21, 2023 05:16
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.

Bug Report: Incremental backup not working as described
3 participants