[#2068] writecache: Optimize initial flush existence checking

Signed-off-by: Evgenii Stratonikov <evgeniy@morphbits.ru>
This commit is contained in:
Evgenii Stratonikov 2022-11-17 09:34:15 +03:00 committed by fyrchik
parent 63f604e948
commit 857d2dc3f5
2 changed files with 6 additions and 9 deletions

View file

@ -61,18 +61,14 @@ func (c *cache) initFlushMarks() {
} }
func (c *cache) isFlushed(addr oid.Address) bool { func (c *cache) isFlushed(addr oid.Address) bool {
var existsPrm meta.ExistsPrm var prm meta.StorageIDPrm
existsPrm.SetAddress(addr) prm.SetAddress(addr)
mRes, err := c.metabase.Exists(existsPrm) mRes, err := c.metabase.StorageID(prm)
if err != nil { if err != nil {
return errors.Is(err, meta.ErrObjectIsExpired) || errors.As(err, new(apistatus.ObjectAlreadyRemoved)) return errors.Is(err, meta.ErrObjectIsExpired) || errors.As(err, new(apistatus.ObjectAlreadyRemoved)) || errors.Is(err, apistatus.ObjectNotFound{})
} }
if !mRes.Exists() { res, err := c.blobstor.Exists(common.ExistsPrm{Address: addr, StorageID: mRes.StorageID()})
return false
}
res, err := c.blobstor.Exists(common.ExistsPrm{Address: addr})
return err == nil && res.Exists return err == nil && res.Exists
} }

View file

@ -17,6 +17,7 @@ type Option func(*options)
// meta is an interface for a metabase. // meta is an interface for a metabase.
type metabase interface { type metabase interface {
Exists(meta.ExistsPrm) (meta.ExistsRes, error) Exists(meta.ExistsPrm) (meta.ExistsRes, error)
StorageID(meta.StorageIDPrm) (meta.StorageIDRes, error)
UpdateStorageID(meta.UpdateStorageIDPrm) (meta.UpdateStorageIDRes, error) UpdateStorageID(meta.UpdateStorageIDPrm) (meta.UpdateStorageIDRes, error)
} }