Skip to content

Commit

Permalink
[nspcc-dev#1028] writecache: Mark big objects as flushed after write
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Leonard Lyubich authored and aprasolova committed Mar 5, 2022
1 parent d5d3dee commit 3c2b2af
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion pkg/local_object_storage/writecache/flush.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 3c2b2af

Please sign in to comment.