forked from TrueCloudLab/frostfs-node
[#1559] engine: Do not count logical errors as storage ones
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
parent
c8911d72d0
commit
40a56c6b42
3 changed files with 36 additions and 2 deletions
|
@ -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 {
|
||||
_, 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
|
||||
|
|
|
@ -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,8 +22,15 @@ func (e *StorageEngine) exists(addr oid.Address) (bool, error) {
|
|||
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)
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
if !exists {
|
||||
exists = res.Exists()
|
||||
|
|
|
@ -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)
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue