Skip to content

Commit

Permalink
fix: value log GC issue with Badger DB in multi-bucket mode (#66)
Browse files Browse the repository at this point in the history
  • Loading branch information
silenceqi authored Jan 16, 2025
1 parent 1ee31ab commit 9768562
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions plugins/badger/badger.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,15 @@ func (filter *Module) Open() error {

if filter.cfg.ValueLogGCEnabled {
global.RegisterBackgroundCallback(&global.BackgroundTask{Tag: "badger_gc", Func: func() {
err := filter.bucket.RunValueLogGC(filter.cfg.ValueLogDiscardRatio)
if err != nil && err != badger.ErrNoRewrite {
log.Error(err)
}
buckets.Range(func(key, value interface{}) bool {
if db, ok := value.(*badger.DB); ok {
err := db.RunValueLogGC(filter.cfg.ValueLogDiscardRatio)
if err != nil && err != badger.ErrNoRewrite {
log.Errorf("running value log gc failed: %v", err)
}
}
return true
})
}, Interval: time.Duration(filter.cfg.ValueLogGCIntervalInSeconds) * time.Second})
}

Expand Down

0 comments on commit 9768562

Please sign in to comment.