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/builtin context when doing AddFiles #16806

Merged
merged 3 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions go/vt/mysqlctl/builtinbackupengine.go
Original file line number Diff line number Diff line change
Expand Up @@ -399,8 +399,8 @@ func (be *BuiltinBackupEngine) executeFullBackup(ctx context.Context, params Bac
// Save initial state so we can restore.
replicaStartRequired := false
sourceIsPrimary := false
superReadOnly := true //nolint
readOnly := true //nolint
superReadOnly := true // nolint
readOnly := true // nolint
var replicationPosition replication.Position
semiSyncSource, semiSyncReplica := params.Mysqld.SemiSyncEnabled(ctx)

Expand Down Expand Up @@ -793,7 +793,11 @@ func (bp *backupPipe) ReportProgress(period time.Duration, logger logutil.Logger
// backupFile backs up an individual file.
func (be *BuiltinBackupEngine) backupFile(ctx context.Context, params BackupParams, bh backupstorage.BackupHandle, fe *FileEntry, name string) (finalErr error) {
ctx, cancel := context.WithCancel(ctx)
defer cancel()
defer func() {
if finalErr != nil {
cancel()
}
}()
// Open the source file for reading.
openSourceAt := time.Now()
source, err := fe.open(params.Cnf, true)
Expand Down
21 changes: 20 additions & 1 deletion go/vt/mysqlctl/s3backupstorage/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ import (
"github.com/aws/smithy-go/middleware"
"github.com/spf13/pflag"

smithyendpoints "github.com/aws/smithy-go/endpoints"
Copy link
Member

Choose a reason for hiding this comment

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

nit: I don't see why this needs an override.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed via 1102c59, we still need an override though using simply "endpoints", the IDE and compiler was not happy. Not exactly sure why, but in the migration docs, they also use override, and the package is named "transport" (even if the path is endpoint), so i ended up overriding it by "transport".


"vitess.io/vitess/go/vt/concurrency"
"vitess.io/vitess/go/vt/log"
stats "vitess.io/vitess/go/vt/mysqlctl/backupstats"
Expand Down Expand Up @@ -110,6 +112,23 @@ var logNameMap logNameToLogLevel

const sseCustomerPrefix = "sse_c:"

type endpointResolver struct {
r s3.EndpointResolverV2
endpoint *string
}

func (er *endpointResolver) ResolveEndpoint(ctx context.Context, params s3.EndpointParameters) (smithyendpoints.Endpoint, error) {
params.Endpoint = er.endpoint
return er.r.ResolveEndpoint(ctx, params)
}

func newEndpointResolver() *endpointResolver {
return &endpointResolver{
r: s3.NewDefaultEndpointResolverV2(),
endpoint: &endpoint,
Copy link
Contributor

Choose a reason for hiding this comment

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

Would be nice IMO to have a comment about what this is here:

Suggested change
endpoint: &endpoint,
endpoint: &endpoint, // Use default endpoint of amazonaws.com

Copy link
Member Author

Choose a reason for hiding this comment

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

this is already the case in the variable definition:

// AWS endpoint, defaults to amazonaws.com but appliances may use a different location
	endpoint string

}
}

type iClient interface {
manager.UploadAPIClient
manager.DownloadAPIClient
Expand Down Expand Up @@ -493,7 +512,7 @@ func (bs *S3BackupStorage) client() (*s3.Client, error) {
o.RetryMaxAttempts = retryCount
o.Retryer = &ClosedConnectionRetryer{}
}
})
}, s3.WithEndpointResolverV2(newEndpointResolver()))

if len(bucket) == 0 {
return nil, fmt.Errorf("--s3_backup_storage_bucket required")
Expand Down
Loading