flag to enable GC during compaction, disabled for now

This commit is contained in:
vyzo 2021-02-26 12:47:27 +02:00
parent f6c930d0aa
commit 7044e623f9

View File

@ -38,6 +38,8 @@ func init() {
type SplitStore struct { type SplitStore struct {
compacting int32 compacting int32
enableGC bool // TODO disabled for now, as it causes panics
baseEpoch abi.ChainEpoch baseEpoch abi.ChainEpoch
mx sync.Mutex mx sync.Mutex
@ -431,8 +433,28 @@ func (s *SplitStore) compact() {
panic(err) panic(err)
} }
if mark { if s.enableGC {
// the object is reachable in the cold range, move it to the cold store 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) blk, err := s.hot.Get(cid)
if err != nil { if err != nil {
// TODO do something better here // TODO do something better here
@ -445,9 +467,11 @@ func (s *SplitStore) compact() {
panic(err) panic(err)
} }
stCold++ if mark {
} else { stCold++
stDead++ } else {
stDead++
}
} }
// delete the object from the hotstore // delete the object from the hotstore