Refine Read method of MinioChunkManager (#22257)

Signed-off-by: jaime <yun.zhang@zilliz.com>
pull/22313/head
jaime 2023-02-21 10:34:26 +08:00 committed by GitHub
parent cd2e7fa535
commit eac4523c79
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 3 deletions

View File

@ -25,7 +25,6 @@ import (
"sync"
"github.com/golang/protobuf/proto"
"go.opentelemetry.io/otel"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
"golang.org/x/sync/errgroup"
@ -4735,8 +4734,8 @@ func (node *Proxy) CheckHealth(ctx context.Context, request *milvuspb.CheckHealt
}
func (node *Proxy) RenameCollection(ctx context.Context, req *milvuspb.RenameCollectionRequest) (*commonpb.Status, error) {
ctx, sp := otel.Tracer(typeutil.ProxyRole).Start(ctx, "Proxy-RefreshPolicyInfoCache")
defer sp.End()
sp, ctx := trace.StartSpanFromContextWithOperationName(ctx, "Proxy-RenameCollection")
defer sp.Finish()
log := log.Ctx(ctx).With(
zap.String("role", typeutil.ProxyRole),

View File

@ -235,6 +235,18 @@ func (mcm *MinioChunkManager) Read(ctx context.Context, filePath string) ([]byte
}
defer object.Close()
// Prefetch object data
var empty []byte
_, err = object.Read(empty)
if err != nil {
errResponse := minio.ToErrorResponse(err)
if errResponse.Code == "NoSuchKey" {
return nil, WrapErrNoSuchKey(filePath)
}
log.Warn("failed to read object", zap.String("path", filePath), zap.Error(err))
return nil, err
}
objectInfo, err := object.Stat()
if err != nil {
log.Warn("failed to stat object", zap.String("path", filePath), zap.Error(err))