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

Key-values that should be deleted are not deleted from disk, even when Close() is called #72

Closed
stephane-martin opened this issue Jun 25, 2017 · 5 comments
Assignees
Labels
kind/bug Something is broken.

Comments

@stephane-martin
Copy link
Contributor

Hello,

OS: MacOSX
Badger version: 20170624

First process:

  • create an empty badger with default options
  • insert a key value K1, V1, with a pretty long value (> 20 chars)
  • delete K1
  • close the badger
  • end the program

Second process:

  • open the same badger
  • try to read K1, V1
  • K1, V1 is still present in the badger...

Thank you

@stephane-martin
Copy link
Contributor Author

stephane-martin commented Jun 25, 2017

Run twice

fmt.Println("testBadger called")
opts := badger.DefaultOptions
dir := "/Users/stef/tmp"
opts.Dir = dir
opts.ValueDir = dir
b, err := badger.NewKV(&opts)
if err != nil {
    fmt.Println("error")
    return
}
key := []byte("key")
item := badger.KVItem{}
b.Get(key, &item)
if item.Value() == nil {
    fmt.Println("non existent key")
    val := []byte("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789FOOBARZOGZOG")
    b.Set(key, val)
    fmt.Println("key value has been inserted")
    b.Get(key, &item)
    fmt.Println("getting the value")
    fmt.Println(string(item.Value()))
    b.Delete(key)
    fmt.Println("key value has been deleted")
    fmt.Println("getting the value again")
    b.Get(key, &item)
    fmt.Println(item.Value())
} else {
    fmt.Println("key exists")
    fmt.Println(string(item.Value()))
}
b.Close()

@pawanrawal pawanrawal self-assigned this Jun 26, 2017
@pawanrawal
Copy link
Contributor

Hi @stephane-martin, thanks for the bug report. I have submitted a fix and this shouldn't be a problem anymore.

@stephane-martin
Copy link
Contributor Author

The fix works, thanks!

@manishrjain
Copy link
Contributor

I'm actually not sure why this is the case. If you close cleanly, then Badger should not have to replay the value log, which means the delete markers in value log won't be required.

There's something else going on here, which is causing value log to be replayed even when Badger is closed properly. We should look into why that is happening.

@manishrjain manishrjain reopened this Jun 27, 2017
@manishrjain manishrjain added the kind/bug Something is broken. label Jun 29, 2017
@pawanrawal
Copy link
Contributor

We update valuePointer even if Fid and Offset are 0 and it has length and we replay from end of last entry instead of start so we don't need to have delete markers anymore.

ngaut pushed a commit to ngaut/badger that referenced this issue Feb 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something is broken.
Development

No branches or pull requests

3 participants