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

Data structure corruption caused by snapshot open/close. #13

Open
danjacques opened this issue Dec 23, 2016 · 0 comments
Open

Data structure corruption caused by snapshot open/close. #13

danjacques opened this issue Dec 23, 2016 · 0 comments

Comments

@danjacques
Copy link

Hey! While working on a downstream project, I traced a problem that I was experiencing back to what I believe is a corruption bug that manifests when using snapshots. I haven't had time to burrow into it yet, but I came away with this fairly minimal reproduction:

package main

import (
        "fmt"

        "github.com/luci/gkvlite"
)

func main() {
        // To trigger: secondKey < firstKey, secondKey < lookup
        firstKey, secondKey, lookup := "c", "a", "b"

        s, _ := gkvlite.NewStore(nil)

        c := s.SetCollection("", nil)
        c.Set([]byte(firstKey), []byte("foo"))

        // If these next two lines don't run, everything works great.
        snap1 := s.Snapshot()
        snap1.Close()

        c.Set([]byte(secondKey), []byte("bar"))
        v, err := c.Get([]byte(lookup))
        fmt.Println(v, err)
}

Prints: [] missing item after item.read() in GetItem()

If the triggering conditions aren't met, if I remove the two snap1 lines, or if I don't close the snapshot, everything works as expected. It looks like there is a corruption of some sort caused by creating and closing snapshots.

I'll take a look deeper tomorrow; just reporting this since now I have a repro.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant