From 72f7df33396cf33106e7b28968581997cba95f61 Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Fri, 19 Feb 2021 11:24:10 +0300 Subject: [PATCH] [#378] shard/gc: Limit the accumulated batch of objects to be deleted Change Shard's garbage remover to interrupt iterating over the metabase graveyard when the buffer is full to the max size (`WithRemoverBatchSize` Shard's option). Signed-off-by: Leonard Lyubich --- pkg/local_object_storage/shard/gc.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/local_object_storage/shard/gc.go b/pkg/local_object_storage/shard/gc.go index 8363ebf9..9b916c1f 100644 --- a/pkg/local_object_storage/shard/gc.go +++ b/pkg/local_object_storage/shard/gc.go @@ -158,12 +158,16 @@ func (s *Shard) removeGarbage() { buf := make([]*object.Address, 0, s.rmBatchSize) // iterate over metabase graveyard and accumulate - // objects with GC mark + // objects with GC mark (no more the s.rmBatchSize objects) err := s.metaBase.IterateOverGraveyard(func(g *meta.Grave) error { if g.WithGCMark() { buf = append(buf, g.Address()) } + if len(buf) == s.rmBatchSize { + return meta.ErrInterruptIterator + } + return nil }) if err != nil {