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

Backup: --incremental-from-pos supports backup name #14923

Merged
merged 18 commits into from
Jan 29, 2024

Conversation

shlomi-noach
Copy link
Contributor

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

Description

Running an incremental backup, up till now the flag --incremental-from-pos supported:

  • A position
  • The magic word "auto"

It now also supports a backup name. If such named backup exists, then the incremental backup will start with the position of the named backup.

A bit of refactoring made, especially around endtoend tests, to accommodate.

Docs: vitessio/website#1662 vitessio/website#1667

Related Issue(s)

Fixes #14905

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: Enhancement Logical improvement (somewhere between a bug and feature) Component: Backup and Restore labels Jan 10, 2024
Copy link
Contributor

vitess-bot bot commented Jan 10, 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 10, 2024
@github-actions github-actions bot added this to the v19.0.0 milestone Jan 10, 2024
Copy link

codecov bot commented Jan 10, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

❗ No coverage uploaded for pull request base (main@3091de1). Click here to learn what that means.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #14923   +/-   ##
=======================================
  Coverage        ?   47.64%           
=======================================
  Files           ?     1151           
  Lines           ?   239843           
  Branches        ?        0           
=======================================
  Hits            ?   114281           
  Misses          ?   116963           
  Partials        ?     8599           

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

@shlomi-noach shlomi-noach removed NeedsDescriptionUpdate The description is not clear or comprehensive enough, and needs work 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 10, 2024
@shlomi-noach shlomi-noach requested a review from a team January 11, 2024 06:37
Signed-off-by: Shlomi Noach <[email protected]>
@shlomi-noach
Copy link
Contributor Author

shlomi-noach commented Jan 14, 2024

Documented in vitessio/website#1662 vitessio/website#1667

@shlomi-noach shlomi-noach removed the NeedsWebsiteDocsUpdate What it says label Jan 14, 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. Just a few minor suggestions.

At first I wasn't crazy about re-using the existing flag, but after reading through it and thinking about it I think it's fine. The backup name is a pointer to a pos, whatever pos that file had. We'll just need to document it of course here: https://vitess.io/docs/19.0/user-guides/operating-vitess/backup-and-restore/creating-a-backup/#create-an-incremental-backup-with-vtctl

The only reason that I didn't approve here, is that we should update the --incremental-from-pos/--incremental_from_pos flag related text:

Unless I'm missing something here?

go/vt/mysqlctl/backupengine.go Outdated Show resolved Hide resolved
go/vt/mysqlctl/builtinbackupengine.go Outdated Show resolved Hide resolved
go/vt/mysqlctl/builtinbackupengine.go Outdated Show resolved Hide resolved
shlomi-noach and others added 4 commits January 18, 2024 10:46
Co-authored-by: Matt Lord <[email protected]>
Signed-off-by: Shlomi Noach <[email protected]>
…/vitess into incremental-from-backup-name

Signed-off-by: Shlomi Noach <[email protected]>
Co-authored-by: Matt Lord <[email protected]>
Signed-off-by: Shlomi Noach <[email protected]>
…/vitess into incremental-from-backup-name

Signed-off-by: Shlomi Noach <[email protected]>
shlomi-noach and others added 2 commits January 18, 2024 10:49
Co-authored-by: Matt Lord <[email protected]>
Signed-off-by: Shlomi Noach <[email protected]>
…/vitess into incremental-from-backup-name

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

The only reason that I didn't approve here, is that we should update the --incremental-from-pos/--incremental_from_pos flag related text:

I'm not sure what's going on. I'm absolutely certain I updated the flag docs in all places 😱 . Anyway, updating again.

@shlomi-noach
Copy link
Contributor Author

At first I wasn't crazy about re-using the existing flag, but after reading through it and thinking about it I think it's fine.

I think ideally the flag should be renamed --incremental-from, and then it makes a ton of sense. I can work on transitioning the flag through two versions, in a followup PR.

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

Updated all CLI docs.

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.

Thanks, @shlomi-noach ! ❤️

@shlomi-noach
Copy link
Contributor Author

New docs PR in vitessio/website#1667, cleaner.

@shlomi-noach shlomi-noach requested a review from a team January 28, 2024 14:51
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.

All my comments are minor. Please feel free to merge once they are addressed.

go/cmd/vtbackup/cli/vtbackup.go Outdated Show resolved Hide resolved
go/cmd/vtctldclient/command/backups.go Outdated Show resolved Hide resolved

Backup.Flags().BoolVar(&backupOptions.UpgradeSafe, "upgrade-safe", false, "Whether to use innodb_fast_shutdown=0 for the backup so it is safe to use for MySQL upgrades.")
Root.AddCommand(Backup)

BackupShard.Flags().BoolVar(&backupShardOptions.AllowPrimary, "allow-primary", false, "Allow the primary of a shard to be used for the backup. WARNING: If using the builtin backup engine, this will shutdown mysqld on the primary and stop writes for the duration of the backup.")
BackupShard.Flags().Int32Var(&backupShardOptions.Concurrency, "concurrency", 4, "Specifies the number of compression/checksum jobs to run simultaneously.")
BackupShard.Flags().StringVar(&backupShardOptions.IncrementalFromPos, "incremental-from-pos", "", "Position of previous backup. Default: empty. If given, then this backup becomes an incremental backup from given position. If value is 'auto', backup taken from last successful backup position")
BackupShard.Flags().StringVar(&backupShardOptions.IncrementalFromPos, "incremental-from-pos", "", "Position, or name of backup from which to create an incremental backup. Default: empty. If given, then this backup becomes an incremental backup from given position or given backup. If value is 'auto', backup taken from last successful backup position.")
Copy link
Member

Choose a reason for hiding this comment

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

Make this consistent with the other places.

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.

@@ -291,6 +294,19 @@ func (be *BuiltinBackupEngine) executeIncrementalBackup(ctx context.Context, par
if err != nil {
return false, vterrors.Wrapf(err, "cannot get binary logs in incremental backup")
}

// @@gtid_purged
Copy link
Member

Choose a reason for hiding this comment

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

Is this comment line needed? Doesn't seem to add anything.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed.

@@ -72,7 +72,7 @@ func init() {
func commandBackup(ctx context.Context, wr *wrangler.Wrangler, subFlags *pflag.FlagSet, args []string) error {
concurrency := subFlags.Int32("concurrency", 4, "Specifies the number of compression/checksum jobs to run simultaneously")
allowPrimary := subFlags.Bool("allow_primary", false, "Allows backups to be taken on primary. Warning!! If you are using the builtin backup engine, this will shutdown your primary mysql for as long as it takes to create a backup.")
incrementalFromPos := subFlags.String("incremental_from_pos", "", "Position of previous backup. Default: empty. If given, then this backup becomes an incremental backup from given position. If value is 'auto', backup taken from last successful backup position")
incrementalFromPos := subFlags.String("incremental_from_pos", "", "Position, or name of backup from which to create an incremental backup. Default: empty. If given, then this backup becomes an incremental backup from given position or given backup. If value is 'auto', backup taken from last successful backup position.")
Copy link
Member

Choose a reason for hiding this comment

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

Make this consistent with all other flag docs.

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.

@@ -114,7 +114,7 @@ func (b *backupEventStreamLogger) Send(resp *vtctldatapb.BackupResponse) error {
func commandBackupShard(ctx context.Context, wr *wrangler.Wrangler, subFlags *pflag.FlagSet, args []string) error {
concurrency := subFlags.Int32("concurrency", 4, "Specifies the number of compression/checksum jobs to run simultaneously")
allowPrimary := subFlags.Bool("allow_primary", false, "Whether to use primary tablet for backup. Warning!! If you are using the builtin backup engine, this will shutdown your primary mysql for as long as it takes to create a backup.")
incrementalFromPos := subFlags.String("incremental_from_pos", "", "Position of previous backup. Default: empty. If given, then this backup becomes an incremental backup from given position. If value is 'auto', backup taken from last successful backup position")
incrementalFromPos := subFlags.String("incremental_from_pos", "", "Position, or name of backup from which to create an incremental backup. Default: empty. If given, then this backup becomes an incremental backup from given position or given backup. If value is 'auto', backup taken from last successful backup position.")
Copy link
Member

Choose a reason for hiding this comment

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

And this too.

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 3 commits January 29, 2024 15:05
Co-authored-by: Deepthi Sigireddi <[email protected]>
Signed-off-by: Shlomi Noach <[email protected]>
Co-authored-by: Deepthi Sigireddi <[email protected]>
Signed-off-by: Shlomi Noach <[email protected]>
@shlomi-noach shlomi-noach merged commit b977e51 into vitessio:main Jan 29, 2024
102 checks passed
@shlomi-noach shlomi-noach deleted the incremental-from-backup-name branch January 29, 2024 13:43
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)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incremental backup: backup from specific backup name
3 participants