-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
go/vt/mysqlctl: instrument s3 upload time #12500
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
7de5ece
go/vt/mysqlctl: instrument s3 upload time
maxenglander 454de74
add unit test
maxenglander f46eb56
add release note
maxenglander b70abcc
instrument aws request send
maxenglander bde59c4
revert tests for now
maxenglander cf5b0fc
time and count without bytes
maxenglander ecff61d
revert UploadWithContext back to Upload
maxenglander 86aa0fd
Revert "add release note"
maxenglander 50e8a3e
add v18 changelog
maxenglander fcb05f7
Merge branch 'main' into maxeng-vtb-s3-stats
maxenglander 5a379eb
address pr feedback
maxenglander File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,6 +36,7 @@ import ( | |
"sort" | ||
"strings" | ||
"sync" | ||
"time" | ||
|
||
"github.com/aws/aws-sdk-go/aws" | ||
"github.com/aws/aws-sdk-go/aws/client" | ||
|
@@ -48,6 +49,7 @@ import ( | |
|
||
"vitess.io/vitess/go/vt/concurrency" | ||
"vitess.io/vitess/go/vt/log" | ||
stats "vitess.io/vitess/go/vt/mysqlctl/backupstats" | ||
"vitess.io/vitess/go/vt/mysqlctl/backupstorage" | ||
"vitess.io/vitess/go/vt/servenv" | ||
) | ||
|
@@ -170,16 +172,20 @@ func (bh *S3BackupHandle) AddFile(ctx context.Context, filename string, filesize | |
u.PartSize = partSizeBytes | ||
}) | ||
object := objName(bh.dir, bh.name, filename) | ||
|
||
_, err := uploader.Upload(&s3manager.UploadInput{ | ||
sendStats := bh.bs.params.Stats.Scope(stats.Operation("AWS:Request:Send")) | ||
_, err := uploader.UploadWithContext(ctx, &s3manager.UploadInput{ | ||
Bucket: &bucket, | ||
Key: object, | ||
Body: reader, | ||
ServerSideEncryption: bh.bs.s3SSE.awsAlg, | ||
SSECustomerAlgorithm: bh.bs.s3SSE.customerAlg, | ||
SSECustomerKey: bh.bs.s3SSE.customerKey, | ||
SSECustomerKeyMD5: bh.bs.s3SSE.customerMd5, | ||
}) | ||
}, s3manager.WithUploaderRequestOptions(func(r *request.Request) { | ||
r.Handlers.CompleteAttempt.PushBack(func(r *request.Request) { | ||
sendStats.TimedIncrement(time.Since(r.AttemptTime)) | ||
}) | ||
})) | ||
if err != nil { | ||
reader.CloseWithError(err) | ||
bh.RecordError(err) | ||
|
@@ -212,12 +218,17 @@ func (bh *S3BackupHandle) ReadFile(ctx context.Context, filename string) (io.Rea | |
return nil, fmt.Errorf("ReadFile cannot be called on read-write backup") | ||
} | ||
object := objName(bh.dir, bh.name, filename) | ||
out, err := bh.client.GetObject(&s3.GetObjectInput{ | ||
sendStats := bh.bs.params.Stats.Scope(stats.Operation("AWS:Request:Send")) | ||
out, err := bh.client.GetObjectWithContext(ctx, &s3.GetObjectInput{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not fully sure of the implications of switching to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a good change. |
||
Bucket: &bucket, | ||
Key: object, | ||
SSECustomerAlgorithm: bh.bs.s3SSE.customerAlg, | ||
SSECustomerKey: bh.bs.s3SSE.customerKey, | ||
SSECustomerKeyMD5: bh.bs.s3SSE.customerMd5, | ||
}, func(r *request.Request) { | ||
r.Handlers.CompleteAttempt.PushBack(func(r *request.Request) { | ||
deepthi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
sendStats.TimedIncrement(time.Since(r.AttemptTime)) | ||
}) | ||
}) | ||
if err != nil { | ||
return nil, err | ||
|
@@ -272,6 +283,7 @@ type S3BackupStorage struct { | |
_client *s3.S3 | ||
mu sync.Mutex | ||
s3SSE S3ServerSideEncryption | ||
params backupstorage.Params | ||
} | ||
|
||
// ListBackups is part of the backupstorage.BackupStorage interface. | ||
|
@@ -411,8 +423,7 @@ func (bs *S3BackupStorage) Close() error { | |
} | ||
|
||
func (bs *S3BackupStorage) WithParams(params backupstorage.Params) backupstorage.BackupStorage { | ||
// TODO(maxeng): return a new S3BackupStorage that uses params. | ||
return bs | ||
return &S3BackupStorage{params: params} | ||
} | ||
|
||
var _ backupstorage.BackupStorage = (*S3BackupStorage)(nil) | ||
|
@@ -485,7 +496,7 @@ func objName(parts ...string) *string { | |
} | ||
|
||
func init() { | ||
backupstorage.BackupStorageMap["s3"] = &S3BackupStorage{} | ||
backupstorage.BackupStorageMap["s3"] = &S3BackupStorage{params: backupstorage.NoParams()} | ||
|
||
logNameMap = logNameToLogLevel{ | ||
"LogOff": aws.LogOff, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not fully sure of the implications of switching to
UploadWithContext
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What motivated you to make the change in the first place?
ctx
will have a timeout associated with it. Assuming standard practice,UploadWithContext
will terminate and return if that timeout is exceeded.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Motivation was that I thought
UploadWithContext
let me specify aWithUploaderRequestOptions
, whereasUpload
does not, but now I can see that's not the case, so I have no reason to use this.Maybe specifying a context would be a good thing, but I don't know enough to say that with any confidence. Reverted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Either you should change this back to be consistent with the change in Line 222 (GetObjectWithContext), or change that back to not use a context. I vote for using a context.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops didn't even notice it was in two places when I tried switching back 😮💨
Will switch back to
GetObjectWithContext