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

Fix xtrabackup context when doing AddFiles #16806

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

frouioui
Copy link
Member

@frouioui frouioui commented Sep 18, 2024

Description

This PR fixes a long standing issue in the xtrabackup engine: the context used to AddFiles by the backup storage was canceled before AddFiles had the chance to complete. This problem can be experienced with the S3 backup storage, as it uploads the file through a goroutine, Ceph also does that and have been impacted in the past too. That goroutine wouldn't have time to complete before the XtrabackupEngine.backupFiles function returned and canceled the context through a defer statement. Leading to AddFiles failing since the context we pass got canceled.

To avoid this issue, we never really passed the context down to AddFiles. We attempted to pass the context in #12500 but reverted it in #14311 since #14188 was raised.

This PR fixes that by not canceling the context automatically, but only when the backupFiles return an error. If we have an error anywhere while executing backupFiles we should attempt to cancel the addition of the files, otherwise we can assume there is nothing to cancel. A different goroutine already make sure to cancel the context if we reach a certain timeout when closing the files.

cc @L3o-pold @vczyh as the original authors of the two issues. I have tested this on my end with manual tests (only on S3), but do you mind making sure it fixes your issues?

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 <florent.poinsard@outlook.fr>
Copy link
Contributor

vitess-bot bot commented Sep 18, 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 Sep 18, 2024
@frouioui frouioui removed NeedsDescriptionUpdate The description is not clear or comprehensive enough, and needs work NeedsWebsiteDocsUpdate What it says 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 Sep 18, 2024
@github-actions github-actions bot added this to the v21.0.0 milestone Sep 18, 2024
@frouioui frouioui changed the title Use a context in S3's AddFiles Fix xtrabackup context when doing AddFiles Sep 18, 2024
Copy link

codecov bot commented Sep 19, 2024

Codecov Report

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

Project coverage is 69.52%. Comparing base (56c39b2) to head (ff0f5c8).

Files with missing lines Patch % Lines
go/vt/mysqlctl/xtrabackupengine.go 0.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #16806      +/-   ##
==========================================
- Coverage   69.53%   69.52%   -0.02%     
==========================================
  Files        1567     1567              
  Lines      202388   202390       +2     
==========================================
- Hits       140723   140704      -19     
- Misses      61665    61686      +21     

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

@L3o-pold
Copy link
Collaborator

@frouioui with your PR I can no longer listing backup for example:

/vt/bin/vtctldclient --server=vtctld:15999 --logtostderr=true GetBackups unsharded/-
E0919 12:12:39.588828      27 main.go:56] rpc error: code = Unknown desc = operation error S3: HeadBucket, https response error StatusCode: 301, RequestID: 2ACET95HY572K3PX, HostID: X2nVlauIKbd8pM8PqINAZCTtrmJ7LmHkCHVrCZq9tTbR3cLb8s4AnS/SnrELiZzroPbO69weCZ4=, api error MovedPermanently: Moved Permanently

@frouioui
Copy link
Member Author

@frouioui with your PR I can no longer listing backup for example:

/vt/bin/vtctldclient --server=vtctld:15999 --logtostderr=true GetBackups unsharded/-

E0919 12:12:39.588828      27 main.go:56] rpc error: code = Unknown desc = operation error S3: HeadBucket, https response error StatusCode: 301, RequestID: 2ACET95HY572K3PX, HostID: X2nVlauIKbd8pM8PqINAZCTtrmJ7LmHkCHVrCZq9tTbR3cLb8s4AnS/SnrELiZzroPbO69weCZ4=, api error MovedPermanently: Moved Permanently

Interesting, may I know what flags (redacted) you are using? We recently changed the SDK version, that might be the cause.

@L3o-pold
Copy link
Collaborator

@frouioui --backup_engine_implementation=builtin --s3_backup_aws_region=us-east-1 --s3_backup_storage_bucket=vitess --s3_backup_force_path_style=true --s3_backup_aws_endpoint=http://minio:9000

@deepthi
Copy link
Member

deepthi commented Sep 19, 2024

@L3o-pold could you test GetBackups with #16664? That way we know whether the SDK upgrade is already breaking you without the changes in this PR.

@frouioui
Copy link
Member Author

@L3o-pold could you test GetBackups with #16664? That way we know whether the SDK upgrade is already breaking you without the changes in this PR.

I tested and it is a problem introduced by #16664, it seems to be an issue with Minio and the new connector. I am still investigating

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: v18.0.0-rc1 S3 backup failed to upload Failed to backup to ceph(s3) using xtrabackup
3 participants