-
Notifications
You must be signed in to change notification settings - Fork 8
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 compact() API and auto-rebuild indexes #339
Conversation
There's an error in the test
It happens mostly in CI, hard to reproduce locally. Have to solve this crash before the PR can be said to be ready. |
I fixed this error, it was about When running However, if we are resuming from a crash, then compaction is started automatically by async-append-only-log, and then |
@arj03 Although this is the final task for ssb-db2, I have still 2 TODOs:
|
@@ -774,7 +879,6 @@ exports.init = function (sbot, config) { | |||
getState: () => state, | |||
getIndexes: () => indexes, | |||
getIndex: (index) => indexes[index], | |||
clearIndexes, |
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.
This was something I used in browser core for testing. I don't mind removing this. It's a thin wrapper around indexes reset anyway.
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.
Do you want to bring it back?
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.
Nice work 🚀
Feels crazy to finally merge this, but here we go! |
Benchmark results
|
Context: #306 and ssbc/jitdb#199
This PR adds the
compact()
("async") API to ssb-db2 which just triggers async-append-only-logcompact()
. When it's done, it will rebuild all leveldb indexes from scratch, rebuild private indexes, and partially rebuild jitdb indexes. This is all done in a way that is crash-resistant, capable of resuming where it had stopped. And compaction is guaranteed to not happen concurrently with log.stream that builds indexes, or any jitdb query.