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

Implement a per-file retry mechanism in the BuiltinBackupEngine #17271

Merged
merged 28 commits into from
Dec 9, 2024

Conversation

frouioui
Copy link
Member

@frouioui frouioui commented Nov 21, 2024

Description

This Pull Request adds a retry mechanism to the builtin backup engine, following what was described in #17259.

I have modified how we record errors in the backup engine, to use a new interface named BackupErrorRecorder, the implementation PerFileErrorRecorder groups each error by their filename. It enables the builtin backup engine to figure out which files have failed and restart them.

We retry every file maximum once (set by a constant), if a file fails during its retry we will cancel everything and fail fast.

I also went ahead and changed the cosmetics of our logs a bit to make them more human readable and easier to follow. The attempt number is added to most log lines, the format used if more consistent, filenames are spelled out in more places to ease debugging.

The builtin blackbox tests were changed to include a new set of restore and backup tests that exercise this retry mechanism. Additionally, I added some integration tests for the S3 backups and restores. These tests use Minio so we don't have to manage AWS secrets in our repository and the security burden that goes with it; However, I made it easily possible to run these tests against AWS S3, for local testing.

The changes made on this PR have the side-effect of fixing #16825 for the builtin engine. This was fixed by specifically calling EndBackup before returning from backupFiles function and before backing up the MANIFEST. Calling EndBackup ensures that the backup is 100% complete both locally and on the remote storage, which is an important thing to check as errors can happen asynchronously when writing to the remote storage. The new logic introduced in this PR relies heavily on EndBackup to define if we need to retry any file or if we need to fail the backup process, this has the side-effect of fixing #16825. Below are the snippets that fix the issue for both normal file entries and also for the MANIFEST file:

err := bh.EndBackup(ctx)
if err != nil {
return err
}

err = bh.EndBackup(ctx)
if err != nil {
return err
}

We do call EndBackup very late in the backup process, once we have finished going through all the files, the manifest, restarted mysql, etc. This was bad as we were catching errors only at the very end after having uploaded the MANIFEST and other files.

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

Signed-off-by: Florent Poinsard <[email protected]>
Copy link
Contributor

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

codecov bot commented Nov 22, 2024

Codecov Report

Attention: Patch coverage is 68.07760% with 181 lines in your changes missing coverage. Please review.

Project coverage is 67.50%. Comparing base (0726ea6) to head (24935b2).
Report is 32 commits behind head on main.

Files with missing lines Patch % Lines
go/vt/mysqlctl/s3backupstorage/s3_mock.go 0.00% 121 Missing ⚠️
go/vt/mysqlctl/builtinbackupengine.go 90.20% 24 Missing ⚠️
go/vt/mysqlctl/s3backupstorage/s3.go 53.12% 15 Missing ⚠️
go/vt/mysqlctl/blackbox/utils.go 87.50% 14 Missing ⚠️
go/vt/mysqlctl/errors/errors.go 91.66% 4 Missing ⚠️
go/vt/mysqlctl/cephbackupstorage/ceph.go 0.00% 2 Missing ⚠️
go/vt/mysqlctl/azblobbackupstorage/azblob.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #17271      +/-   ##
==========================================
+ Coverage   67.40%   67.50%   +0.09%     
==========================================
  Files        1574     1580       +6     
  Lines      253221   253805     +584     
==========================================
+ Hits       170690   171336     +646     
+ Misses      82531    82469      -62     

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

@frouioui frouioui force-pushed the retry-failed-files-builtin-engine branch from e306633 to 7db26bc Compare November 25, 2024 19:02
Signed-off-by: Florent Poinsard <[email protected]>
@frouioui frouioui force-pushed the retry-failed-files-builtin-engine branch from c3cf5c9 to 48938fa Compare November 26, 2024 19:10
@frouioui frouioui removed the NeedsDescriptionUpdate The description is not clear or comprehensive enough, and needs work label Nov 29, 2024
@frouioui frouioui force-pushed the retry-failed-files-builtin-engine branch from 655d878 to 82d9baa Compare December 4, 2024 15:49
@harshit-gangal harshit-gangal force-pushed the retry-failed-files-builtin-engine branch from 82d9baa to 655d878 Compare December 4, 2024 15:53
@frouioui frouioui force-pushed the retry-failed-files-builtin-engine branch from 655d878 to 82d9baa Compare December 4, 2024 15:55
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 for working on this, @frouioui ! I only had some minor notes/comments/suggestions.

go/test/endtoend/backup/s3/s3_builtin_test.go Show resolved Hide resolved
go/test/endtoend/backup/s3/s3_builtin_test.go Show resolved Hide resolved
go/test/endtoend/backup/s3/s3_builtin_test.go Show resolved Hide resolved
go/test/endtoend/backup/s3/s3_builtin_test.go Show resolved Hide resolved
go/test/endtoend/backup/s3/s3_builtin_test.go Outdated Show resolved Hide resolved
go/vt/mysqlctl/builtinbackupengine.go Outdated Show resolved Hide resolved
go/vt/mysqlctl/builtinbackupengine.go Show resolved Hide resolved
go/vt/mysqlctl/errorsbackup/errors.go Outdated Show resolved Hide resolved
go/vt/mysqlctl/errorsbackup/errors.go Outdated Show resolved Hide resolved
go/vt/mysqlctl/errorsbackup/errors.go Outdated Show resolved Hide resolved
@frouioui frouioui requested a review from mattlord December 5, 2024 22:09
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.

Nice work on this! ❤️

@deepthi deepthi changed the title Implement a retry mechanism in the BuiltinBackupEngine Implement a per-file retry mechanism in the BuiltinBackupEngine Dec 8, 2024
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.

Nice work! I have just one more cosmetic change request:
s/errorsbackup/errors

Also regarding

The changes made on this PR have the side-effect of fixing #16825 for the builtin engine.

Can you call out the specific bug /race condition at the code level that is being fixed? That will allow people to backport a small change to their forks if they want to.

Signed-off-by: Florent Poinsard <[email protected]>
@frouioui
Copy link
Member Author

frouioui commented Dec 9, 2024

I have just one more cosmetic change request:
s/errorsbackup/errors

Done via 25791d8.

Can you call out the specific bug /race condition at the code level that is being fixed? That will allow people to backport a small change to their forks if they want to.

I have updated the Pull Request description @deepthi.

@frouioui frouioui merged commit 63dfb9e into vitessio:main Dec 9, 2024
100 checks passed
@frouioui frouioui deleted the retry-failed-files-builtin-engine branch December 9, 2024 20:20
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.

BuiltinBackupEngine: Retry failed files
4 participants