diff --git a/pkg/local_object_storage/engine/delete.go b/pkg/local_object_storage/engine/delete.go index 45fec21d..ccf64ca6 100644 --- a/pkg/local_object_storage/engine/delete.go +++ b/pkg/local_object_storage/engine/delete.go @@ -5,6 +5,7 @@ import ( "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/shard" apistatus "github.com/nspcc-dev/neofs-sdk-go/client/status" + objectSDK "github.com/nspcc-dev/neofs-sdk-go/object" oid "github.com/nspcc-dev/neofs-sdk-go/object/id" ) @@ -72,7 +73,13 @@ func (e *StorageEngine) delete(prm DeletePrm) (DeleteRes, error) { resExists, err := sh.Exists(existsPrm) if err != nil { - e.reportShardError(sh, "could not check object existence", err) + _, ok := err.(*objectSDK.SplitInfoError) + if ok || shard.IsErrRemoved(err) { + return true + } + if !shard.IsErrNotFound(err) { + e.reportShardError(sh, "could not check object existence", err) + } return false } else if !resExists.Exists() { return false diff --git a/pkg/local_object_storage/engine/exists.go b/pkg/local_object_storage/engine/exists.go index 4822752d..a0d8549e 100644 --- a/pkg/local_object_storage/engine/exists.go +++ b/pkg/local_object_storage/engine/exists.go @@ -3,6 +3,7 @@ package engine import ( "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/shard" apistatus "github.com/nspcc-dev/neofs-sdk-go/client/status" + objectSDK "github.com/nspcc-dev/neofs-sdk-go/object" oid "github.com/nspcc-dev/neofs-sdk-go/object/id" ) @@ -21,7 +22,14 @@ func (e *StorageEngine) exists(addr oid.Address) (bool, error) { return true } - e.reportShardError(sh, "could not check existence of object in shard", err) + _, ok := err.(*objectSDK.SplitInfoError) + if ok { + return true + } + if !shard.IsErrNotFound(err) { + e.reportShardError(sh, "could not check existence of object in shard", err) + } + return false } if !exists { diff --git a/pkg/local_object_storage/metabase/exists_test.go b/pkg/local_object_storage/metabase/exists_test.go index 8e03c0f8..155d04be 100644 --- a/pkg/local_object_storage/metabase/exists_test.go +++ b/pkg/local_object_storage/metabase/exists_test.go @@ -5,8 +5,10 @@ import ( "testing" "github.com/nspcc-dev/neofs-node/pkg/core/object" + apistatus "github.com/nspcc-dev/neofs-sdk-go/client/status" cidtest "github.com/nspcc-dev/neofs-sdk-go/container/id/test" objectSDK "github.com/nspcc-dev/neofs-sdk-go/object" + oidtest "github.com/nspcc-dev/neofs-sdk-go/object/id/test" "github.com/stretchr/testify/require" ) @@ -28,6 +30,15 @@ func TestDB_Exists(t *testing.T) { exists, err := metaExists(db, object.AddressOf(regular)) require.NoError(t, err) require.True(t, exists) + + t.Run("removed object", func(t *testing.T) { + err := metaInhume(db, object.AddressOf(regular), oidtest.Address()) + require.NoError(t, err) + + exists, err := metaExists(db, object.AddressOf(regular)) + require.ErrorAs(t, err, new(apistatus.ObjectAlreadyRemoved)) + require.False(t, exists) + }) }) t.Run("tombstone object", func(t *testing.T) { @@ -152,4 +163,12 @@ func TestDB_Exists(t *testing.T) { require.Equal(t, id1, id2) }) }) + + t.Run("random object", func(t *testing.T) { + addr := oidtest.Address() + + exists, err := metaExists(db, addr) + require.NoError(t, err) + require.False(t, exists) + }) }