From 3c2b2aff2e7a334fec338a96888e427eea4261b0 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 5b8333b5b2..3d15de1a5a 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: