Skip to content

Commit

Permalink
Use a context in S3's AddFiles
Browse files Browse the repository at this point in the history
Signed-off-by: Florent Poinsard <[email protected]>
  • Loading branch information
frouioui committed Sep 18, 2024
1 parent 56c39b2 commit ff0f5c8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
3 changes: 1 addition & 2 deletions go/vt/mysqlctl/s3backupstorage/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,7 @@ func (bh *S3BackupHandle) AddFile(ctx context.Context, filename string, filesize
})
object := objName(bh.dir, bh.name, filename)
sendStats := bh.bs.params.Stats.Scope(stats.Operation("AWS:Request:Send"))
// Using UploadWithContext breaks uploading to Minio and Ceph https://github.com/vitessio/vitess/issues/14188
_, err := uploader.Upload(context.Background(), &s3.PutObjectInput{
_, err := uploader.Upload(ctx, &s3.PutObjectInput{
Bucket: &bucket,
Key: &object,
Body: reader,
Expand Down
9 changes: 8 additions & 1 deletion go/vt/mysqlctl/xtrabackupengine.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,8 +316,15 @@ func (be *XtrabackupEngine) backupFiles(
// would impose a timeout that starts counting right now, so it would
// include the time spent uploading the file content. We only want to impose
// a timeout on the final Close() step.
// This context also allows us to immediately abort AddFiles if we encountered
// an error in this function.
addFilesCtx, cancelAddFiles := context.WithCancel(ctx)
defer cancelAddFiles()
defer func() {
if finalErr != nil {
cancelAddFiles()
}
}()

destFiles, err := addStripeFiles(addFilesCtx, params, bh, backupFileName, numStripes)
if err != nil {
return replicationPosition, vterrors.Wrapf(err, "cannot create backup file %v", backupFileName)
Expand Down

0 comments on commit ff0f5c8

Please sign in to comment.