# Are there any plans to automate RunValueLogGC

**URL:** <https://discuss.dgraph.io/t/are-there-any-plans-to-automate-runvalueloggc/12753>\
**Category:** Badger\
**Created:** [February 12, 2021, 9:20am UTC](https://discuss.dgraph.io/t/are-there-any-plans-to-automate-runvalueloggc/12753 "2021-02-12T09:20:10Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![harshalchaudhari](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/harshalchaudhari/32/6245_2.png) [@harshalchaudhari](https://discuss.dgraph.io/u/harshalchaudhari)\
**Post date:** [February 12, 2021, 9:20am UTC](https://discuss.dgraph.io/t/are-there-any-plans-to-automate-runvalueloggc/12753/1 "2021-02-12T09:20:10Z")

</div>

Hi Guys,  
We are evaluating if we can use badgerDB here at Mixpanel to replace our file based manifests. I have couple of questions regarding db.RunValueLogGC.  
Is it correct understanding that currently valueLogGC is not triggered automatically in any way?  
Is it intentional to leave it upto users to do db.RunValueLogGC periodically? Is it possible to automate it.  
If it is not intentional , I can help put PR to automate it. Let me know your thoughts on it.  
Harshal

---

<div class="post-metadata">

**Author:** ![chewxy](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/chewxy/32/4339_2.png) [@chewxy](https://discuss.dgraph.io/u/chewxy)\
**Post date:** [February 15, 2021, 1:28am UTC](https://discuss.dgraph.io/t/are-there-any-plans-to-automate-runvalueloggc/12753/2 "2021-02-15T01:28:50Z")

</div>

I do believe that is correct (as far as my code grepping goes). @ibrahim might be able to chime in a bit more

---

<div class="post-metadata">

**Author:** ![harshalchaudhari](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/harshalchaudhari/32/6245_2.png) [@harshalchaudhari](https://discuss.dgraph.io/u/harshalchaudhari)\
**Post date:** [February 15, 2021, 6:19am UTC](https://discuss.dgraph.io/t/are-there-any-plans-to-automate-runvalueloggc/12753/3 "2021-02-15T06:19:31Z")

</div>

yeah, for more context , we have a system where we add millions of KVs to badgerDB (key contains timestamp of when they were added) and every 30 minutes, we delete all the KVs from badgerDB that are atleast 10 days old. (we want to keep track of those KVs for 10 days)  
We have never run db.RunValueLogGC , does that mean, we have never actually deleted any values yet? From what I could grep , I see db.RunValueLogGC is the only thing that truly deletes values from badgerDB. Is that correct?  
Lately iterating on prefix periodically (every 30 minutes) has been using lot of CPU (see attached image of a profile) . I suspect it might be because we never ran db.RunValueLogGC.

 ![Screen Shot 2021-02-14 at 10.16.46 PM](https://canada1.discourse-cdn.com/flex007/uploads/dgraph/original/2X/a/a9d26b3303b1e516690d7e163c458f100df7ae67.jpeg)

Or if not that , does deleting lot of KVs while iterating through them can cause this?

---

<div class="post-metadata">

**Author:** ![chewxy](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/chewxy/32/4339_2.png) [@chewxy](https://discuss.dgraph.io/u/chewxy)\
**Post date:** [February 15, 2021, 11:42pm UTC](https://discuss.dgraph.io/t/are-there-any-plans-to-automate-runvalueloggc/12753/4 "2021-02-15T23:42:27Z")

</div>

@naman, thoughts?

---

<div class="post-metadata">

**Author:** ![Naman](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/naman/32/3498_2.png) [@Naman](https://discuss.dgraph.io/u/Naman)\
**Post date:** [February 17, 2021, 9:46am UTC](https://discuss.dgraph.io/t/are-there-any-plans-to-automate-runvalueloggc/12753/5 "2021-02-17T09:46:58Z")

</div>

Hey @harshalchaudhari, correct that vlog GC does not happens automatically. One need to trigger that via `db.RunValueLogGC`. That’s how dgraph does it as well [https://github.com/dgraph-io/dgraph/blob/832ebb9766f1732186eaecbf3792aff9e3766c6c/x/x.go#L1089-L1127](https://github.com/dgraph-io/dgraph/blob/832ebb9766f1732186eaecbf3792aff9e3766c6c/x/x.go#L1089-L1127).

> [@harshalchaudhari](#):
>
> We have never run db.RunValueLogGC , does that mean, we have never actually deleted any values yet?

Only the values bigger than `vlogThreshold` goes into the value log. So for the KVs that lie entirely in LSM tree(with values \< vlogThreshold) would be eventually be cleaned up via compactions. But the values that went into value log will not be cleaned and will use the disk space, unless you run the value log GC.

> [@harshalchaudhari](#):
>
> Is it intentional to leave it upto users to do db.RunValueLogGC periodically? Is it possible to automate it.  
> If it is not intentional , I can help put PR to automate it. Let me know your thoughts on it.

@ibrahim any thoughts on having a way for automatic vlog GC? I believe that the vlog GC was left up to the users because it was earlier used as write-ahead-log that a user may want to keep. I think that will be good to have functionality with configurable parameters.
