[#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 <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2021-02-19 11:24:10 +03:00 committed by Alex Vanin
parent f5f416268f
commit 72f7df3339

View file

@ -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 {