[#1028] writecache: Mark big objects as flushed after write

Make `flushBigObjects` routine to mark objects which are written to
`BlobStor`. This prevents already flushed objects from being written on
the next iterator tick.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2021-12-09 15:29:31 +03:00 committed by Alex Vanin
parent bd4d17ef9e
commit d246e5193b

View file

@ -117,13 +117,20 @@ func (c *cache) flushBigObjects() {
select {
case <-tick.C:
_ = c.fsTree.Iterate(func(addr *objectSDK.Address, data []byte) error {
if _, ok := c.store.flushed.Peek(addr.String()); ok {
sAddr := addr.String()
if _, ok := c.store.flushed.Peek(sAddr); ok {
return nil
}
if _, err := c.blobstor.PutRaw(addr, data); err != nil {
c.log.Error("cant flush object to blobstor", zap.Error(err))
return nil
}
// mark object as flushed
c.store.flushed.Add(sAddr, false)
return nil
})
case <-c.closeCh: