-
Notifications
You must be signed in to change notification settings - Fork 137
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
add a BadgerDB backend #115
Conversation
Taken from https://gist.github.com/melekes/85b8c07dd917828dc2ac6696129b73f2 as of June 2020, plus 'go mod tidy' to add the dependencies.
Mainly, many now return errors, so we can get rid of all panics. Also add the missing BackendType.
The commented out code might be useful in the future, but it's in the git history anyway.
Codecov Report
@@ Coverage Diff @@
## master #115 +/- ##
==========================================
+ Coverage 68.86% 70.61% +1.75%
==========================================
Files 26 27 +1
Lines 1593 1746 +153
==========================================
+ Hits 1097 1233 +136
- Misses 429 441 +12
- Partials 67 72 +5
|
CI is failing because interfacer is complaining about an unexported function. You should disable that linter altogether - that warning isn't particularly useful :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great work @mvdan 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could badger_db.go
be broken out to match the file structure of other dbs?
badger_db.go is under 300 lines, so I would generally not split it up. The current file structure seems a bit weird to me, with over a dozen files under 100 lines, and over 30 files total. But if you strongly prefer consistency, I can split it up. |
Two follow-up comments:
|
it should be fine since there will be a followup to restructuring the package. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, thanks @mvdan! Can you add a README description and changelog entry as well please?
The tests here are passing, but I assume something will fail once tendermint is properly tested with this code. Can someone with more tendermint experience help?
The Tendermint end-to-end tests pass, but IAVL fails with a panic. I believe this is caused by the lack of iter.Valid()
checks, we should add a tm-db test case for this as well:
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x40 pc=0x45102e6]
goroutine 174 [running]:
testing.tRunner.func1.1(0x48400e0, 0x4f26760)
/usr/local/Cellar/go/1.14.4/libexec/src/testing/testing.go:940 +0x2f5
testing.tRunner.func1(0xc0001dd8c0)
/usr/local/Cellar/go/1.14.4/libexec/src/testing/testing.go:943 +0x3f9
panic(0x48400e0, 0x4f26760)
/usr/local/Cellar/go/1.14.4/libexec/src/runtime/panic.go:969 +0x166
github.com/dgraph-io/badger/v2.(*Item).Key(...)
/Users/erik/Projects/go/pkg/mod/github.com/dgraph-io/badger/[email protected]/iterator.go:70
github.com/dgraph-io/badger/v2.(*Iterator).Item(...)
/Users/erik/Projects/go/pkg/mod/github.com/dgraph-io/badger/[email protected]/iterator.go:504
github.com/tendermint/tm-db.(*BadgerDB).iteratorOpts(0xc000010068, 0xc0003b6a20, 0x9, 0x9, 0xc0003b6a00, 0x9, 0x9, 0x1, 0x64, 0x1, ...)
/Users/erik/Projects/tendermint/tm-db/badger_db.go:140 +0x266
github.com/tendermint/tm-db.(*BadgerDB).ReverseIterator(0xc000010068, 0xc0003b6a00, 0x9, 0x9, 0xc0003b6a20, 0x9, 0x9, 0x401571c, 0xc00009f100, 0x8, ...)
It would be interesting to get some benchmark numbers. I can help if you can point me at a benchmark that is bottlenecked by the database, and that reflects somewhat realistic usage.
The best option would probably be Cosmos SDK simulations, which use tm-db via IAVL. I'm not very familiar with these though, as it's managed by a different team.
For sure.
Thanks, I'll take a look.
Sounds good - I'll wait for someone from that team to give some insight, then. Benchmarking should probably come once the reviews are done. |
@alexanderbez Do you have any SDK sims that would be suitable for benchmarking database backends with realistic workloads? |
Only thing that comes to mind is simulation benchmarking, which you can look into. Although, you should be able to get away with a pretty easy one-off benchmark, where you create a simapp with a corresponding backend, begin block, deliver txs, end block, commit, repeat. |
Thanks Bez. I don't think benchmarks are necessary to merge this, especially since we don't really have a good general-purpose benchmarking suite at the moment. If you want to spend some time on it @mvdan then it's definitely welcome, but otherwise we can punt it and do some performance optimizations later if necessary. |
Passing all the relevant tests.
It's been deprecated for years and for good reason. The warning it was showing in this branch wasn't useful.
How did you run those iavl tests, beyond replacing the tm-db module with my branch? I assume you had to make some change somewhere to use the badger backend, because I don't think iavl tests against all tm-db backends. Also, your suspicion about that missing
Should be all good to go, I think, unless there are other iavl panics or errors. |
Also, I've kept multiple commits, but I've also merged some changes together to not explode this into 15 commits. I think this is nicer as a series of commits than as a single commit conflating my work with Anton's. |
Thanks @mvdan! IAVL tests pass - to run them, I point Could you update the
Thanks! We prefer to squash-merge PRs, since this makes it easier to e.g. cherry-pick or revert them. |
Whoops, forgot about those. Done.
Of course - I would probably go for the same :) Do you want me to squash myself then, to provide a good commit message on the squashed commit? Or are you OK with a squashed commit message that simply lists all original commit messages? |
Thanks! I can squash-merge it. |
With multiple commits, to show the incremental changes on top of Anton's work in
early 2019.
Updates #38.