[server] Log slow replication upload (#2966)

## Description

## Tests
This commit is contained in:
Manav Rathi 2024-08-27 10:07:40 +05:30 committed by GitHub
commit e2c3b625db
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -26,6 +26,11 @@ import (
"github.com/spf13/viper"
)
const (
slowUploadThreshold = 2 * time.Second
slowSpeedThreshold = 0.5 // MB/s
)
// ReplicationController3 oversees version 3 of our object replication.
//
// The user's encrypted data starts off in 1 hot storage (Backblaze "b2"). This
@ -423,6 +428,7 @@ type UploadInput struct {
// Upload, verify and then update the DB to mark replication to dest.
func (c *ReplicationController3) replicateFile(in *UploadInput, dest *UploadDestination, dbUpdateCopies func() error) error {
start := time.Now()
logger := in.Logger.WithFields(log.Fields{
"destination": dest.Label,
"bucket": *dest.Bucket,
@ -438,6 +444,19 @@ func (c *ReplicationController3) replicateFile(in *UploadInput, dest *UploadDest
if err != nil {
return failure(stacktrace.Propagate(err, "Failed to upload object"))
}
// log if time taken is more than 2 seconds and speed is less than .5MB/s
if dest.Label == "wasabi" && time.Since(start) > slowUploadThreshold {
elapsed := time.Since(start)
uploadSpeedMBps := float64(in.ExpectedSize) / (elapsed.Seconds() * 1024 * 1024)
if uploadSpeedMBps < slowSpeedThreshold {
logger.WithFields(log.Fields{
"sizeBytes": in.ExpectedSize,
"speedMBps": uploadSpeedMBps,
"elapsedSecs": elapsed.Seconds(),
}).Infof("Slow replication upload to %s: %.2f seconds, speed: %.2f MB/s", dest.Label, elapsed.Seconds(), uploadSpeedMBps)
}
}
err = c.verifyUploadedFileSize(in, dest)
if err != nil {