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

reindexEncrypted needs to be crash-resistant #407

Open
staltz opened this issue Nov 16, 2022 · 6 comments · May be fixed by #419
Open

reindexEncrypted needs to be crash-resistant #407

staltz opened this issue Nov 16, 2022 · 6 comments · May be fixed by #419
Labels
enhancement 🌱 New feature or request

Comments

@staltz
Copy link
Member

staltz commented Nov 16, 2022

Context: ssbc/ssb-box2#22

There could be a feature in ssb-db2's reindexEncrypted where it is crash-resistant. Since reindexEncrypted takes no arguments, this is just a matter of storing a boolean in some file (or just the file existence can be the "true" boolean) and then once ssb-db2 starts up it resumes reindexEncrypted if that file exists. Note also that reindexEncrypted does not need to be atomic. Any subset of encrypted records that got decrypted is some partial progress, and then after app restart, the progress can continue.

Also, another thing I notice is that it seems reindexEncrypted is not very efficient, at least not with jitdb. If there are encrypted records at seq 6, 14, 18, 22, and assume max seq is 100 then it'll reindex jitdb from seq 6–100, then reindex 14–100, then 18–100, then 22–100. It could just pick the minimum (6) and do 6–100 once.

@arj03
Copy link
Member

arj03 commented Dec 9, 2022

About this:

Also, another thing I notice is that it seems reindexEncrypted is not very efficient, at least not with jitdb. If there are encrypted records at seq 6, 14, 18, 22, and assume max seq is 100 then it'll reindex jitdb from seq 6–100, then reindex 14–100, then 18–100, then 22–100. It could just pick the minimum (6) and do 6–100 once.

This assumes that something comes in and does a query in jitdb between the reindex calls. In jitdb we just reset the indexes so they will be re-created on next query. So if there is nothing concurrent this should only do 1 reindex from 6, right?

@staltz
Copy link
Member Author

staltz commented Dec 9, 2022

Ooooh

@staltz staltz changed the title reindexEncrypted needs to be crash-resistant reindexEncrypted needs to be crash-resistant Jan 4, 2023
@staltz
Copy link
Member Author

staltz commented Jan 17, 2023

Yeah, so let's drop that jitdb optimization idea, you were right.

The "boolean" file in disk to trigger resume of reindexedEncrypted is still going to be relevant to implement.

@staltz
Copy link
Member Author

staltz commented Jan 18, 2023

I got a test written for this, and I got the implementation written correctly, but my implementation isn't passing the tests due to some odd issue with jitdb. Maybe one day we can try having a pair programming debugging.

@arj03
Copy link
Member

arj03 commented Jan 18, 2023

Okay, maybe friday afternoon @staltz ? I'm a big hung up right now.

@staltz
Copy link
Member Author

staltz commented Jan 18, 2023

Sounds good. This isn't a blocker right now.

@staltz staltz linked a pull request Jan 31, 2023 that will close this issue
@staltz staltz linked a pull request Jan 31, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement 🌱 New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants