From 6b680d112b1fb1652d3dc69abd4be9486d5ea257 Mon Sep 17 00:00:00 2001 From: vyzo Date: Tue, 2 Mar 2021 22:48:35 +0200 Subject: [PATCH] do tracker purge in smaller batches --- blockstore/splitstore/splitstore.go | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/blockstore/splitstore/splitstore.go b/blockstore/splitstore/splitstore.go index 0e4c3e150..67588fe9c 100644 --- a/blockstore/splitstore/splitstore.go +++ b/blockstore/splitstore/splitstore.go @@ -727,9 +727,24 @@ func (s *SplitStore) purgeBlocks(cids []cid.Cid) error { } func (s *SplitStore) purgeTracking(cids []cid.Cid) error { - err := s.tracker.DeleteBatch(cids) - if err != nil { - return xerrors.Errorf("error deleting batch from tracker: %w", err) + if len(cids) == 0 { + return nil + } + + // don't delete one giant batch of 7M objects, but rather do smaller batches + done := false + for i := 0; done; i++ { + start := i * batchSize + end := start + batchSize + if end >= len(cids) { + end = len(cids) + done = true + } + + err := s.tracker.DeleteBatch(cids[start:end]) + if err != nil { + return xerrors.Errorf("error deleting batch from tracker: %w", err) + } } return nil