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:
/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())
                return
        }

        fmt.Fprintf(w, "success")
        return
}

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

I have 2 records in the DB with this info:

|---|---|
|cpucount:|4|
|docker0:|172.17.0.1/16|
|ens192:|10.10.36.87/24|
|hostname:|pu-dlrinventorylz-01|
|lo:|127.0.0.1/8|
|memory:|8185937920|
|os:|linux|
|registered_time:|1546877824|
|update_time:|1547047625|

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.