diff --git a/pkg/local_object_storage/engine/delete.go b/pkg/local_object_storage/engine/delete.go index 2ddcb6530..0af893997 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" ) @@ -57,6 +58,10 @@ func (e *StorageEngine) delete(prm DeletePrm) (DeleteRes, error) { resExists, err := sh.Exists(existsPrm) if err != nil { + _, ok := err.(*objectSDK.SplitInfoError) + if ok && shard.IsErrNotFound(err) && shard.IsErrRemoved(err) { + return true + } if resExists.FromMeta() { e.reportShardError(sh, sh.metaErrorCount, "could not check object existence", err) } diff --git a/pkg/local_object_storage/engine/exists.go b/pkg/local_object_storage/engine/exists.go index 0b975fa72..3b287e87b 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,9 +22,16 @@ func (e *StorageEngine) exists(addr oid.Address) (bool, error) { return true } + _, ok := err.(*objectSDK.SplitInfoError) + if ok || shard.IsErrNotFound(err) { + return true + } + if res.FromMeta() { e.reportShardError(sh, sh.metaErrorCount, "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 02dacfb3b..659d3d0fe 100644 --- a/pkg/local_object_storage/metabase/exists_test.go +++ b/pkg/local_object_storage/metabase/exists_test.go @@ -6,8 +6,10 @@ import ( "github.com/nspcc-dev/neofs-node/pkg/core/object" meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase" + 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" ) @@ -29,6 +31,15 @@ func TestDB_Exists(t *testing.T) { exists, err := meta.Exists(db, object.AddressOf(regular)) require.NoError(t, err) require.True(t, exists) + + t.Run("removed object", func(t *testing.T) { + err := meta.Inhume(db, object.AddressOf(regular), oidtest.Address()) + require.NoError(t, err) + + exists, err := meta.Exists(db, object.AddressOf(regular)) + require.ErrorAs(t, err, new(apistatus.ObjectAlreadyRemoved)) + require.False(t, exists) + }) }) t.Run("tombstone object", func(t *testing.T) { @@ -153,4 +164,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 := meta.Exists(db, addr) + require.NoError(t, err) + require.False(t, exists) + }) }