Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interruptable garbage collection #1324

Closed
Stebalien opened this issue May 6, 2020 · 2 comments
Closed

Interruptable garbage collection #1324

Stebalien opened this issue May 6, 2020 · 2 comments
Labels
kind/enhancement Something could be better. status/accepted We accept to investigate or work on it.

Comments

@Stebalien
Copy link
Contributor

What version of Go are you using (go version)?

$ go version
go version go1.14.2 amd64/linux

What operating system are you using?

Linux

What version of Badger are you using?

v1.6.1

Description

RunValueLogGC cannot be interrupted and can potentially run for minutes on a large enough datastore. This can be a problem if garbage collection is running on shutdown.

It would be nice to be able to pass a context to RunValueLogGC to cancel the process early. Alternatively, allowing a concurrent call to Close to interrupt a GC run would fix this. However, at the moment, close can't be called concurrently with anything else.

Would a new RunValueLogGCWithContext function be considered if a patch were proposed?

@jarifibrahim
Copy link
Contributor

This looks like a useful enhancement since GC could take minutes at times to complete.The GC has two steps. The first sampling step can be exited at any time.

badger/value.go

Line 1628 in 536fed1

func (vlog *valueLog) doRunGC(lf *logFile, discardRatio float64, tr trace.Trace) (err error) {
The second step is where we rewrite the value log file. I'm wondering if there would be any side effects of stopping the rewrite while it's running

badger/value.go

Line 499 in 536fed1

func (vlog *valueLog) rewrite(f *logFile, tr trace.Trace) error {

@jarifibrahim jarifibrahim added the kind/enhancement Something could be better. label May 9, 2020
@stale stale bot added the status/stale The issue hasn't had activity for a while and it's marked for closing. label Jun 8, 2020
@jarifibrahim jarifibrahim added status/accepted We accept to investigate or work on it. and removed status/stale The issue hasn't had activity for a while and it's marked for closing. labels Jun 8, 2020
@dgraph-io dgraph-io deleted a comment from stale bot Jun 8, 2020
@minhaj-shakeel
Copy link

Github issues have been deprecated.
This issue has been moved to discuss. You can follow the conversation there and also subscribe to updates by changing your notification preferences.

drawing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement Something could be better. status/accepted We accept to investigate or work on it.
Development

No branches or pull requests

3 participants