From d246e5193b277857ac47f17144c7bad03a2c7a6e Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Thu, 9 Dec 2021 15:29:31 +0300 Subject: [PATCH] [#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 --- pkg/local_object_storage/writecache/flush.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pkg/local_object_storage/writecache/flush.go b/pkg/local_object_storage/writecache/flush.go index 5b8333b5..3d15de1a 100644 --- a/pkg/local_object_storage/writecache/flush.go +++ b/pkg/local_object_storage/writecache/flush.go @@ -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: