[#230] engine: Stop on first SplitInfoError in Get method

Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
Alex Vanin 2020-12-03 13:01:09 +03:00
parent a488d202e1
commit 3a37eda410
3 changed files with 14 additions and 23 deletions

View file

@ -43,9 +43,10 @@ func (r *GetRes) Object() *object.Object {
// Returns ErrNotFound if requested object is missing in local storage. // Returns ErrNotFound if requested object is missing in local storage.
func (e *StorageEngine) Get(prm *GetPrm) (*GetRes, error) { func (e *StorageEngine) Get(prm *GetPrm) (*GetRes, error) {
var ( var (
obj *object.Object obj *object.Object
siErr *objectSDK.SplitInfoError
alreadyRemoved = false outError = object.ErrNotFound
) )
shPrm := new(shard.GetPrm). shPrm := new(shard.GetPrm).
@ -57,8 +58,10 @@ func (e *StorageEngine) Get(prm *GetPrm) (*GetRes, error) {
switch { switch {
case errors.Is(err, object.ErrNotFound): case errors.Is(err, object.ErrNotFound):
return false // ignore, go to next shard return false // ignore, go to next shard
case errors.Is(err, object.ErrAlreadyRemoved): case
alreadyRemoved = true errors.Is(err, object.ErrAlreadyRemoved),
errors.As(err, &siErr):
outError = err
return true // stop, return it back return true // stop, return it back
default: default:
@ -79,11 +82,7 @@ func (e *StorageEngine) Get(prm *GetPrm) (*GetRes, error) {
}) })
if obj == nil { if obj == nil {
if alreadyRemoved { return nil, outError
return nil, object.ErrAlreadyRemoved
}
return nil, object.ErrNotFound
} }
return &GetRes{ return &GetRes{

View file

@ -46,7 +46,7 @@ func (e *StorageEngine) Head(prm *HeadPrm) (*HeadRes, error) {
var ( var (
head *object.Object head *object.Object
alreadyRemoved = false outError = object.ErrNotFound
) )
shPrm := new(shard.HeadPrm). shPrm := new(shard.HeadPrm).
@ -59,7 +59,7 @@ func (e *StorageEngine) Head(prm *HeadPrm) (*HeadRes, error) {
case errors.Is(err, object.ErrNotFound): case errors.Is(err, object.ErrNotFound):
return false // ignore, go to next shard return false // ignore, go to next shard
case errors.Is(err, object.ErrAlreadyRemoved): case errors.Is(err, object.ErrAlreadyRemoved):
alreadyRemoved = true outError = err
return true // stop, return it back return true // stop, return it back
default: default:
@ -80,11 +80,7 @@ func (e *StorageEngine) Head(prm *HeadPrm) (*HeadRes, error) {
}) })
if head == nil { if head == nil {
if alreadyRemoved { return nil, outError
return nil, object.ErrAlreadyRemoved
}
return nil, object.ErrNotFound
} }
return &HeadRes{ return &HeadRes{

View file

@ -61,7 +61,7 @@ func (e *StorageEngine) GetRange(prm *RngPrm) (*RngRes, error) {
var ( var (
obj *object.Object obj *object.Object
alreadyRemoved = false outError = object.ErrNotFound
) )
shPrm := new(shard.RngPrm). shPrm := new(shard.RngPrm).
@ -75,7 +75,7 @@ func (e *StorageEngine) GetRange(prm *RngPrm) (*RngRes, error) {
case errors.Is(err, object.ErrNotFound): case errors.Is(err, object.ErrNotFound):
return false // ignore, go to next shard return false // ignore, go to next shard
case errors.Is(err, object.ErrAlreadyRemoved): case errors.Is(err, object.ErrAlreadyRemoved):
alreadyRemoved = true outError = err
return true // stop, return it back return true // stop, return it back
default: default:
@ -96,11 +96,7 @@ func (e *StorageEngine) GetRange(prm *RngPrm) (*RngRes, error) {
}) })
if obj == nil { if obj == nil {
if alreadyRemoved { return nil, outError
return nil, object.ErrAlreadyRemoved
}
return nil, object.ErrNotFound
} }
return &RngRes{ return &RngRes{