-
Notifications
You must be signed in to change notification settings - Fork 937
Added purge subcommand to purge beacon chain db #971
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
Conversation
|
@michaelsproul perhaps this will interest you. It seems we might be missing the freezer DB here. Do you have suggestions on the best way to get the paths for both DBs? |
michaelsproul
left a comment
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 looks good!
As Paul said, we should also purge the freezer database. I think it's reasonable for now to purge whatever directory the user has provided. The function to get the freezer DB is get_freezer_db_path on ClientConfig. In the long-run, it might be worth adding a confirmation for the deletion of both DBs.
The other thing we need before merging is for CI to pass. You can enable it on your fork by enabling Github actions: https://github.com/ethDreamer/lighthouse/actions. We're waiting on Github to improve this workflow -- we can also trigger a run manually if you're confident it will pass (right now it will fail because of formatting).
beacon_node/client/src/config.rs
Outdated
| let data_dir = self.get_data_dir() | ||
| .ok_or("Failed to get data_dir".to_string())?; | ||
| let trap_file = data_dir.join(CHAIN_DB_PURGED_TRAP_FILE); | ||
| fs::File::create(trap_file).map_err( |err| { |
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.
Thinking about the case where the purge fails midway but the trap file has been created: I think it's ok, because the user will probably get errors when the partially deleted database tries to reinitialise. The alternative is creating the trap file afterwards, in which case the user will probably get errors to do with resuming from a deleted DB. In both cases, they'll probably try a re-purge.
I've made these changes
I believe I've enabled them but I'm not completely sure? Let me know if I need to do something else. |
Improved formatting, added remove freezer db, created function get_db_purged_trap_file_path
f72b5cc to
18de29b
Compare
Issue Addressed
#829
Proposed Changes
There's now a purge subcommand for the beacon node. The user can run this when the chain_db gets in a bad state. The next time they run the client it will rebuild the chain_db.
Additional Info
This is my first-ever Rust PR, there may be better ways of doing these things so feel free to request changes / give feedback.