[#1559] engine: Do not count logical errors as storage ones

Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
Evgenii Stratonikov 2022-07-01 14:21:33 +03:00 committed by fyrchik
parent c8911d72d0
commit 40a56c6b42
3 changed files with 36 additions and 2 deletions

View file

@ -5,6 +5,7 @@ import (
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/shard" "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/shard"
apistatus "github.com/nspcc-dev/neofs-sdk-go/client/status" 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" 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) resExists, err := sh.Exists(existsPrm)
if err != nil { if err != nil {
_, ok := err.(*objectSDK.SplitInfoError)
if ok || shard.IsErrRemoved(err) {
return true
}
if !shard.IsErrNotFound(err) {
e.reportShardError(sh, "could not check object existence", err) e.reportShardError(sh, "could not check object existence", err)
}
return false return false
} else if !resExists.Exists() { } else if !resExists.Exists() {
return false return false

View file

@ -3,6 +3,7 @@ package engine
import ( import (
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/shard" "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/shard"
apistatus "github.com/nspcc-dev/neofs-sdk-go/client/status" 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" oid "github.com/nspcc-dev/neofs-sdk-go/object/id"
) )
@ -21,8 +22,15 @@ func (e *StorageEngine) exists(addr oid.Address) (bool, error) {
return true return true
} }
_, ok := err.(*objectSDK.SplitInfoError)
if ok {
return true
}
if !shard.IsErrNotFound(err) {
e.reportShardError(sh, "could not check existence of object in shard", err) e.reportShardError(sh, "could not check existence of object in shard", err)
} }
return false
}
if !exists { if !exists {
exists = res.Exists() exists = res.Exists()

View file

@ -5,8 +5,10 @@ import (
"testing" "testing"
"github.com/nspcc-dev/neofs-node/pkg/core/object" "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" cidtest "github.com/nspcc-dev/neofs-sdk-go/container/id/test"
objectSDK "github.com/nspcc-dev/neofs-sdk-go/object" 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" "github.com/stretchr/testify/require"
) )
@ -28,6 +30,15 @@ func TestDB_Exists(t *testing.T) {
exists, err := metaExists(db, object.AddressOf(regular)) exists, err := metaExists(db, object.AddressOf(regular))
require.NoError(t, err) require.NoError(t, err)
require.True(t, exists) 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) { t.Run("tombstone object", func(t *testing.T) {
@ -152,4 +163,12 @@ func TestDB_Exists(t *testing.T) {
require.Equal(t, id1, id2) 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)
})
} }