[#2016] shard: Check meta first on Get

`meta` should prevent returning removed objects (`GCMark` and `TS` relations
are `meta` abstractions).

Signed-off-by: Pavel Karpy <p.karpy@yadro.com>
This commit is contained in:
Pavel Karpy 2022-12-20 16:27:03 +03:00 committed by Anton Nikiforov
parent 74ec71446f
commit 21717262ec
2 changed files with 14 additions and 13 deletions

View file

@ -69,6 +69,7 @@ Changelog for NeoFS Node
- Prevent leaking goroutines in the tree service (#2162) - Prevent leaking goroutines in the tree service (#2162)
- Do not search for LOCK objects when delete container when session provided (#2152) - Do not search for LOCK objects when delete container when session provided (#2152)
- Race conditions on shard's mode switch (#1956) - Race conditions on shard's mode switch (#1956)
- Returning expired/removed objects from write-cache (#2016)
### Removed ### Removed
- `-g` option from `neofs-cli control ...` and `neofs-cli container create` commands (#2089) - `-g` option from `neofs-cli control ...` and `neofs-cli container create` commands (#2089)

View file

@ -98,19 +98,6 @@ func (s *Shard) fetchObjectData(addr oid.Address, skipMeta bool, cb storFetcher,
res *objectSDK.Object res *objectSDK.Object
) )
if s.hasWriteCache() {
res, err := wc(s.writeCache)
if err == nil || IsErrOutOfRange(err) {
return res, false, err
}
if IsErrNotFound(err) {
s.log.Debug("object is missing in write-cache")
} else {
s.log.Error("failed to fetch object from write-cache", zap.Error(err))
}
}
var exists bool var exists bool
if !skipMeta { if !skipMeta {
var mPrm meta.ExistsPrm var mPrm meta.ExistsPrm
@ -123,6 +110,19 @@ func (s *Shard) fetchObjectData(addr oid.Address, skipMeta bool, cb storFetcher,
exists = mRes.Exists() exists = mRes.Exists()
} }
if s.hasWriteCache() {
res, err = wc(s.writeCache)
if err == nil || IsErrOutOfRange(err) {
return res, false, err
}
if IsErrNotFound(err) {
s.log.Debug("object is missing in write-cache")
} else {
s.log.Error("failed to fetch object from write-cache", zap.Error(err))
}
}
if skipMeta || err != nil { if skipMeta || err != nil {
res, err = cb(s.blobStor, nil) res, err = cb(s.blobStor, nil)
return res, false, err return res, false, err