From bb6d93adad86ea51fdc50f34825efb45584be5df Mon Sep 17 00:00:00 2001 From: zenground0 Date: Thu, 26 Dec 2024 17:43:27 +0530 Subject: [PATCH] Fix hang with crazy map allocation --- blockstore/splitstore/markset_map.go | 5 +++++ blockstore/splitstore/splitstore_warmup.go | 5 +---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/blockstore/splitstore/markset_map.go b/blockstore/splitstore/markset_map.go index 52efcb8a484..922800eafad 100644 --- a/blockstore/splitstore/markset_map.go +++ b/blockstore/splitstore/markset_map.go @@ -42,6 +42,11 @@ func NewMapMarkSetEnv(path string) (*MapMarkSetEnv, error) { func (e *MapMarkSetEnv) New(name string, sizeHint int64) (MarkSet, error) { path := filepath.Join(e.path, name) + // Limit map size to 1k if sizeHint exceeds this value + // This prevents accidental hanging when sizeHint is too large + if sizeHint > 1000 { + sizeHint = 1000 + } return &MapMarkSet{ set: make(map[string]struct{}, sizeHint), path: path, diff --git a/blockstore/splitstore/splitstore_warmup.go b/blockstore/splitstore/splitstore_warmup.go index e57ea25a525..14107510404 100644 --- a/blockstore/splitstore/splitstore_warmup.go +++ b/blockstore/splitstore/splitstore_warmup.go @@ -59,10 +59,7 @@ func (s *SplitStore) doWarmup2(curTs *types.TipSet) error { log.Infow("warmup starting") epoch := curTs.Height() - count := new(int64) - // Empirically taken from December 2024 - *count = MarkSetEstimate - s.markSetSize = *count + *count>>2 // overestimate a bit + s.markSetSize = MarkSetEstimate err := s.ds.Put(s.ctx, markSetSizeKey, int64ToBytes(s.markSetSize)) if err != nil { log.Warnf("error saving mark set size: %s", err)