frostfs-node/pkg/local_object_storage/engine/exists.go
Evgenii Stratonikov 6ad2624552 [#1118] engine: allow to set error threshold
There are certain errors which are not expected during usual node
operation and which tell us that something is wrong with the shard.
To prevent possible data corruption, move shard in read-only mode after
amount of errors exceeded some threshold. By default no actions are performed.

Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2022-02-03 15:14:27 +03:00

40 lines
847 B
Go

package engine
import (
"errors"
"github.com/nspcc-dev/neofs-node/pkg/core/object"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/shard"
objectSDK "github.com/nspcc-dev/neofs-sdk-go/object"
)
func (e *StorageEngine) exists(addr *objectSDK.Address) (bool, error) {
shPrm := new(shard.ExistsPrm).WithAddress(addr)
alreadyRemoved := false
exists := false
e.iterateOverSortedShards(addr, func(_ int, sh hashedShard) (stop bool) {
res, err := sh.Exists(shPrm)
if err != nil {
if errors.Is(err, object.ErrAlreadyRemoved) {
alreadyRemoved = true
return true
}
e.reportShardError(sh, "could not check existence of object in shard", err)
}
if res != nil && !exists {
exists = res.Exists()
}
return false
})
if alreadyRemoved {
return false, object.ErrAlreadyRemoved
}
return exists, nil
}