From 21717262ec66cb2da29474a65fde19d2b69aeaf2 Mon Sep 17 00:00:00 2001 From: Pavel Karpy Date: Tue, 20 Dec 2022 16:27:03 +0300 Subject: [PATCH] [#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 --- CHANGELOG.md | 1 + pkg/local_object_storage/shard/get.go | 26 +++++++++++++------------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7bee2e25b..07732cc55 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -69,6 +69,7 @@ Changelog for NeoFS Node - Prevent leaking goroutines in the tree service (#2162) - Do not search for LOCK objects when delete container when session provided (#2152) - Race conditions on shard's mode switch (#1956) +- Returning expired/removed objects from write-cache (#2016) ### Removed - `-g` option from `neofs-cli control ...` and `neofs-cli container create` commands (#2089) diff --git a/pkg/local_object_storage/shard/get.go b/pkg/local_object_storage/shard/get.go index 0ff846e99..c728dc1d2 100644 --- a/pkg/local_object_storage/shard/get.go +++ b/pkg/local_object_storage/shard/get.go @@ -98,19 +98,6 @@ func (s *Shard) fetchObjectData(addr oid.Address, skipMeta bool, cb storFetcher, 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 if !skipMeta { var mPrm meta.ExistsPrm @@ -123,6 +110,19 @@ func (s *Shard) fetchObjectData(addr oid.Address, skipMeta bool, cb storFetcher, 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 { res, err = cb(s.blobStor, nil) return res, false, err