-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[BUG]: Panic when closing DB while other goroutines doing reads #1923
Comments
When I try to read the key on the same goroutine after closing the database, there's no panic but a func main() {
db, err := badger.Open(badger.DefaultOptions(dir))
if err != nil {
log.Fatalln(err)
}
key := []byte("key")
err = db.Update(func(txn *badger.Txn) error {
return txn.Set(key, []byte("value"))
})
if err != nil {
log.Fatalln(err)
}
err = db.Close()
if err != nil {
log.Fatalln(err)
}
err = db.View(func(txn *badger.Txn) error {
_, err := txn.Get(key)
return err
})
if err != nil {
log.Println(err)
}
} |
Hi @mdogan, Thank you for filling a detailed issue. You are right I think that we could have better protection around closing the database. Though, usually it is expected that no operation is in flight or done after database is closed. If you have a solution, please feel free to create a PR for it. This would be a low priority issue for us, but we will try to get to it as soon as we can. |
Will this (or any other fix) be backported to v3? |
@solracsf we do not have such plans, but if you are looking for something specific, please let us know. We may consider it. Additionally, we don't have major changes from v3 to v4, it should be easy enough for you to upgrade. If you are facing issues in upgrade, do let us know. |
Ok thanks, no problem, will consider v3 as deprecated and plan to upgrade to v4 (as soon as our app support Go 1.19+, actually on 1.18). 👍 |
What version of Badger are you using?
Both
v3.2103.5
andv4.1.0
What version of Go are you using?
Have you tried reproducing the issue with the latest release?
Yes
What is the hardware spec (RAM, CPU, OS)?
What steps will reproduce the bug?
Expected behavior and actual result.
Expecting to see; reader goroutines to return
badger.ErrDBClosed
error when database is closed.But got a panic:
Additional information
No response
The text was updated successfully, but these errors were encountered: