do hotstore moving GC in splitstore with a user-specified frequency
This commit is contained in:
parent
c747f2f1e2
commit
fb3986226f
@ -81,6 +81,13 @@ type Config struct {
|
||||
// - a positive integer indicates the number of finalities, outside the compaction boundary,
|
||||
// for which messages will be retained in the hotstore.
|
||||
HotStoreMessageRetention uint64
|
||||
|
||||
// HotstoreMovingGCFrequency indicates how frequently to garbage collect the hotstore using
|
||||
// moving GC (if supported by the hotstore).
|
||||
// A value of 0 disables moving GC entirely.
|
||||
// A positive value is the number of compactions before a moving GC is performed;
|
||||
// a value of 1 will perform moving GC in every compaction.
|
||||
HotStoreMovingGCFrequency uint
|
||||
}
|
||||
|
||||
// ChainAccessor allows the Splitstore to access the chain. It will most likely
|
||||
|
@ -8,17 +8,24 @@ import (
|
||||
)
|
||||
|
||||
func (s *SplitStore) gcHotstore() {
|
||||
if err := s.gcBlockstoreOnline(s.hot); err != nil {
|
||||
var opts map[interface{}]interface{}
|
||||
if s.cfg.HotStoreMovingGCFrequency > 0 && s.compactionIndex%int64(s.cfg.HotStoreMovingGCFrequency) == 0 {
|
||||
opts = map[interface{}]interface{}{
|
||||
bstore.BlockstoreMovingGC: true,
|
||||
}
|
||||
}
|
||||
|
||||
if err := s.gcBlockstore(s.hot, opts); err != nil {
|
||||
log.Warnf("error garbage collecting hostore: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
func (s *SplitStore) gcBlockstoreOnline(b bstore.Blockstore) error {
|
||||
func (s *SplitStore) gcBlockstore(b bstore.Blockstore, opts map[interface{}]interface{}) error {
|
||||
if gc, ok := b.(bstore.BlockstoreGC); ok {
|
||||
log.Info("garbage collecting blockstore")
|
||||
startGC := time.Now()
|
||||
|
||||
if err := gc.CollectGarbage(); err != nil {
|
||||
if err := gc.CollectGarbage(opts); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@ -26,5 +33,5 @@ func (s *SplitStore) gcBlockstoreOnline(b bstore.Blockstore) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
return fmt.Errorf("blockstore doesn't support online gc: %T", b)
|
||||
return fmt.Errorf("blockstore doesn't support garbage collection: %T", b)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user