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

Add option to set a repair callback #700

Merged
merged 1 commit into from
Oct 31, 2023
Merged

Add option to set a repair callback #700

merged 1 commit into from
Oct 31, 2023

Conversation

cberner
Copy link
Owner

@cberner cberner commented Oct 12, 2023

This allows the user to abort the repair process and receive progress notifications

Fixes #639

@cberner cberner force-pushed the repair_callback branch 2 times, most recently from c3dcc7d to 9973a02 Compare October 15, 2023 03:33
@cberner cberner changed the title Add option to set a repair handler callback Add option to set a repair callback Oct 15, 2023
@cberner
Copy link
Owner Author

cberner commented Oct 22, 2023

@veryordinally / @raphjaph can you take a look at this API when you get a chance? Will merge it, if it looks like it covers your use case

This allows the user to abort the repair process and receive progress
notifications
@casey
Copy link
Contributor

casey commented Oct 30, 2023

Nice! This works for us. It looks like Self::verify_primary_checksums(mem) is called first, before the repair callback is invoked. Can this take a long time? If so, it would be nice to do a quick check if anything that takes a long time is going to happen, and call repair_callback first if so. Related, if repair_callback is called first, then having progress return 0 for the first call would avoid needing to check if we should skip printing the message, i.e., we could just do if handle.progress() == 0.0 { print_message() }.

@cberner
Copy link
Owner Author

cberner commented Oct 31, 2023

I think that's already implemented. It's just in the caller of do_repair. See here: https://github.com/cberner/redb/pull/700/files#diff-7d7d3a6ce5c2a3e8b39ce4f49b78a71365c8e06c0d9ddb78bc2dca68bfeb4a5bR683-R688

@casey
Copy link
Contributor

casey commented Oct 31, 2023

Ah, okay awesome. Looks good to me!

@cberner
Copy link
Owner Author

cberner commented Oct 31, 2023

I would recommend against if handle.progress() == 0.0 though. The API doesn't guarantee that the first call will be with a progress value of 0.0 and I might find some reason to change it in the future. Although that does seem unlikely

@cberner cberner merged commit d8c63a9 into master Oct 31, 2023
@cberner cberner deleted the repair_callback branch October 31, 2023 02:07
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

Successfully merging this pull request may close these issues.

Provide a way to test if a database file needs repair before opening it
2 participants