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
f9eb15254e
commit
609dbe83db
3 changed files with 32 additions and 0 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"
|
||||
)
|
||||
|
||||
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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)
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue