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

panic in db.Stats() during db.Close() #418

Open
StephenButtolph opened this issue Aug 8, 2022 · 0 comments
Open

panic in db.Stats() during db.Close() #418

StephenButtolph opened this issue Aug 8, 2022 · 0 comments

Comments

@StephenButtolph
Copy link

StephenButtolph commented Aug 8, 2022

There appears to be a panic bug/race during db.Close() + db.Stat().

  1. The first thing done in db.Stat() is make sure the db isn't closed: https://github.com/syndtr/goleveldb/blob/master/leveldb/db.go#L1075-L1078
  2. If db.Close() is then called (after the aforementioned check), we have this trace:
  3. Then we can call GetStats() on the now closed cache resulting in this trace:

I think the core invariant break is documented here:

MVP test which panics:

package leveldbtest

import (
	"testing"

	"github.com/syndtr/goleveldb/leveldb/cache"
)

func TestLRUCache_GetStatsAfterClose(t *testing.T) {
	c := cache.NewCache(cache.NewLRU(2))
	c.Close(false)
	_ = c.GetStats() // panics
}
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