From 7044e623f9c28d761e23d5323d8c213fe2533c17 Mon Sep 17 00:00:00 2001 From: vyzo Date: Fri, 26 Feb 2021 12:47:27 +0200 Subject: [PATCH] flag to enable GC during compaction, disabled for now --- chain/store/splitstore/splitstore.go | 34 ++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/chain/store/splitstore/splitstore.go b/chain/store/splitstore/splitstore.go index 19f2c6f12..d1edd9715 100644 --- a/chain/store/splitstore/splitstore.go +++ b/chain/store/splitstore/splitstore.go @@ -38,6 +38,8 @@ func init() { type SplitStore struct { compacting int32 + enableGC bool // TODO disabled for now, as it causes panics + baseEpoch abi.ChainEpoch mx sync.Mutex @@ -431,8 +433,28 @@ func (s *SplitStore) compact() { panic(err) } - if mark { - // the object is reachable in the cold range, move it to the cold store + if s.enableGC { + if mark { + // the object is reachable in the cold range, move it to the cold store + blk, err := s.hot.Get(cid) + if err != nil { + // TODO do something better here + panic(err) + } + + err = s.cold.Put(blk) + if err != nil { + // TODO do something better here + panic(err) + } + + stCold++ + } else { + // the object will be deleted + stDead++ + } + } else { + // if GC is disabled, we move both cold and dead objects to the coldstore blk, err := s.hot.Get(cid) if err != nil { // TODO do something better here @@ -445,9 +467,11 @@ func (s *SplitStore) compact() { panic(err) } - stCold++ - } else { - stDead++ + if mark { + stCold++ + } else { + stDead++ + } } // delete the object from the hotstore