[#1461] shard: Add a separate ErrLockObjectRemoval

Do not return `meta.ErrLockObjectRemoval` from shard's methods, add shard's
own error for that.

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
Pavel Karpy 2022-07-07 15:46:17 +03:00 committed by fyrchik
parent 558cc1193a
commit cb0bb7207c
2 changed files with 10 additions and 1 deletions

View file

@ -158,7 +158,7 @@ func (e *StorageEngine) inhumeAddr(addr oid.Address, prm shard.InhumePrm, checkE
case errors.As(err, &errLocked):
status = 1
return true
case errors.Is(err, meta.ErrLockObjectRemoval):
case errors.Is(err, shard.ErrLockObjectRemoval):
status = 2
return true
}

View file

@ -2,6 +2,7 @@ package shard
import (
"context"
"errors"
"fmt"
meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase"
@ -50,6 +51,10 @@ func (p *InhumePrm) ForceRemoval() {
}
}
// ErrLockObjectRemoval is returned when inhume operation is being
// performed on lock object, and it is not a forced object removal.
var ErrLockObjectRemoval = meta.ErrLockObjectRemoval
// Inhume calls metabase. Inhume method to mark object as removed. It won't be
// removed physically from blobStor and metabase until `Delete` operation.
//
@ -84,6 +89,10 @@ func (s *Shard) Inhume(prm InhumePrm) (InhumeRes, error) {
res, err := s.metaBase.Inhume(metaPrm)
if err != nil {
if errors.Is(err, meta.ErrLockObjectRemoval) {
return InhumeRes{}, ErrLockObjectRemoval
}
s.log.Debug("could not mark object to delete in metabase",
zap.String("error", err.Error()),
)