fix: do not log concurrently when multiple disks return errors (#15044)

since the values inside 'context' are mutated internally by
logger, make sure to log serially upon errors not concurrently.
This commit is contained in:
Harshavardhana
2022-06-06 15:15:11 -07:00
committed by GitHub
parent 31c4fdbf79
commit df9eeb7f8f
3 changed files with 29 additions and 24 deletions

View File

@@ -137,24 +137,26 @@ func readAllFileInfo(ctx context.Context, disks []StorageAPI, bucket, object, ve
return errDiskNotFound
}
metadataArray[index], err = disks[index].ReadVersion(ctx, bucket, object, versionID, readData)
if err != nil {
if !IsErr(err, []error{
errFileNotFound,
errVolumeNotFound,
errFileVersionNotFound,
errDiskNotFound,
}...) {
logger.LogOnceIf(ctx, fmt.Errorf("Drive %s, path (%s/%s) returned an error (%w)",
disks[index], bucket, object, err),
disks[index].String())
}
}
return err
}, index)
}
errs := g.Wait()
for index, err := range errs {
if !IsErr(err, []error{
errFileNotFound,
errVolumeNotFound,
errFileVersionNotFound,
errDiskNotFound,
}...) {
logger.LogOnceIf(ctx, fmt.Errorf("Drive %s, path (%s/%s) returned an error (%w)",
disks[index], bucket, object, err),
disks[index].String())
}
}
// Return all the metadata.
return metadataArray, g.Wait()
return metadataArray, errs
}
// shuffleDisksAndPartsMetadataByIndex this function should be always used by GetObjectNInfo()