mirror of
https://github.com/minio/minio.git
synced 2024-12-24 06:05:55 -05:00
Avoid double bucket validation in DeleteObjectHandler (#6720)
On a heavily loaded server, getBucketInfo() becomes slow, one can easily observe deleting an object causes many additional network calls. This PR is to let the underlying call return the actual error and write it back to the client.
This commit is contained in:
parent
9fe51e392b
commit
36990aeafd
@ -2091,21 +2091,18 @@ func (api objectAPIHandlers) DeleteObjectHandler(w http.ResponseWriter, r *http.
|
|||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
getBucketInfo := objectAPI.GetBucketInfo
|
|
||||||
if api.CacheAPI() != nil {
|
|
||||||
getBucketInfo = api.CacheAPI().GetBucketInfo
|
|
||||||
}
|
|
||||||
if _, err := getBucketInfo(ctx, bucket); err != nil {
|
|
||||||
writeErrorResponse(w, toAPIErrorCode(err), r.URL)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// http://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectDELETE.html
|
// http://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectDELETE.html
|
||||||
// Ignore delete object errors while replying to client, since we are
|
if err := deleteObject(ctx, objectAPI, api.CacheAPI(), bucket, object, r); err != nil {
|
||||||
// suppposed to reply only 204. Additionally log the error for
|
switch toAPIErrorCode(err) {
|
||||||
// investigation.
|
case ErrNoSuchBucket:
|
||||||
deleteObject(ctx, objectAPI, api.CacheAPI(), bucket, object, r)
|
// When bucket doesn't exist specially handle it.
|
||||||
|
writeErrorResponse(w, ErrNoSuchBucket, r.URL)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
logger.LogIf(ctx, err)
|
||||||
|
// Ignore delete object errors while replying to client, since we are suppposed to reply only 204.
|
||||||
|
}
|
||||||
writeSuccessNoContent(w)
|
writeSuccessNoContent(w)
|
||||||
}
|
}
|
||||||
|
@ -984,13 +984,13 @@ func (xl xlObjects) DeleteObject(ctx context.Context, bucket, object string) (er
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if !xl.isObject(bucket, object) && !xl.isObjectDir(bucket, object) {
|
|
||||||
return ObjectNotFound{bucket, object}
|
|
||||||
}
|
|
||||||
|
|
||||||
var writeQuorum int
|
var writeQuorum int
|
||||||
var isObjectDir = hasSuffix(object, slashSeparator)
|
var isObjectDir = hasSuffix(object, slashSeparator)
|
||||||
|
|
||||||
|
if isObjectDir && !xl.isObjectDir(bucket, object) {
|
||||||
|
return toObjectErr(errFileNotFound, bucket, object)
|
||||||
|
}
|
||||||
|
|
||||||
if isObjectDir {
|
if isObjectDir {
|
||||||
writeQuorum = len(xl.getDisks())/2 + 1
|
writeQuorum = len(xl.getDisks())/2 + 1
|
||||||
} else {
|
} else {
|
||||||
|
@ -305,7 +305,7 @@ func readXLMeta(ctx context.Context, disk StorageAPI, bucket string, object stri
|
|||||||
// Reads entire `xl.json`.
|
// Reads entire `xl.json`.
|
||||||
xlMetaBuf, err := disk.ReadAll(bucket, path.Join(object, xlMetaJSONFile))
|
xlMetaBuf, err := disk.ReadAll(bucket, path.Join(object, xlMetaJSONFile))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err != errFileNotFound {
|
if err != errFileNotFound && err != errVolumeNotFound {
|
||||||
logger.GetReqInfo(ctx).AppendTags("disk", disk.String())
|
logger.GetReqInfo(ctx).AppendTags("disk", disk.String())
|
||||||
logger.LogIf(ctx, err)
|
logger.LogIf(ctx, err)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user