Skip to content

Commit

Permalink
Fix DB GC
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Andersen committed Oct 18, 2018
1 parent 0459c97 commit 8750a24
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 18 deletions.
35 changes: 18 additions & 17 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions core/queues.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,10 +242,21 @@ func NewQManager(cfg *QManagerConfig) (*QManager, error) {
return nil, err
}
go rv.bgTasks()
go rv.trimDB()

return rv, nil
}

func (qm *QManager) trimDB() {
for {
time.Sleep(5 * time.Minute)
again:
err := qm.db.RunValueLogGC(0.5)
if err == nil {
goto again
}
}
}
func (qm *QManager) Shutdown() {
qm.qzmu.Lock()
for _, q := range qm.qz {
Expand Down
13 changes: 12 additions & 1 deletion core/routing.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"time"

"github.com/dgraph-io/badger"
"github.com/gogo/protobuf/proto"
"github.com/golang/protobuf/proto"
"github.com/immesys/wave/wve"
pb "github.com/immesys/wavemq/mqpb"
"github.com/prometheus/client_golang/prometheus"
Expand Down Expand Up @@ -286,9 +286,20 @@ func NewTerminus(qm *QManager, am *AuthModule, cfg *RoutingConfig) (*Terminus, e

//Run the BG tasks
go rv.bgTasks()
go rv.trimDB()
return rv, nil
}

func (t *Terminus) trimDB() {
for {
time.Sleep(30 * time.Minute)
again:
err := t.db.RunValueLogGC(0.5)
if err == nil {
goto again
}
}
}
func (t *Terminus) RouterID() string {
return t.ourNodeId
}
Expand Down

0 comments on commit 8750a24

Please sign in to comment.