GC Timing With Badger

(Sovereign313) #1

So, I’ve built an http server for api requests that use badgerDB… I have an endpoint to call GC:

Which runs this code:

func handleGC(w http.ResponseWriter, r *http.Request) {
        err := db.RunValueLogGC(0.7)
        if err != nil {
                fmt.Fprintf(w, err.Error())

        fmt.Fprintf(w, "success")

It responds with:
Value log GC attempt didn’t result in any cleanup.

I have 2 records in the DB with this info:


The size of the vlog is 224k with every updated “Set” from the start. Why isn’t /gc cleaning up these entries?

(Sovereign313) #2

bump? does GC have to be run in some background go routine? I’ve tried that too, with no luck. runValueLogGC just doesn’t seem to collect anything… is it a size thing? Do I have to wait for the vlog to get so big before it will collect?

(Manish R Jain) #3

GC won’t clean up if there’s only one value log file. In general, GC isn’t that aggressive, because disk is cheap.

(Sovereign313) #4

Awesome. Thanks you.