From cb0bb7207c4564125e48f83e7031cfb551c721f2 Mon Sep 17 00:00:00 2001 From: Pavel Karpy Date: Thu, 7 Jul 2022 15:46:17 +0300 Subject: [PATCH] [#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 --- pkg/local_object_storage/engine/inhume.go | 2 +- pkg/local_object_storage/shard/inhume.go | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/pkg/local_object_storage/engine/inhume.go b/pkg/local_object_storage/engine/inhume.go index c333bdfcf..f50e96ed8 100644 --- a/pkg/local_object_storage/engine/inhume.go +++ b/pkg/local_object_storage/engine/inhume.go @@ -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 } diff --git a/pkg/local_object_storage/shard/inhume.go b/pkg/local_object_storage/shard/inhume.go index ef4c7bb20..c154317bb 100644 --- a/pkg/local_object_storage/shard/inhume.go +++ b/pkg/local_object_storage/shard/inhume.go @@ -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()), )