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

Added leap-util subcommand to check for a clean shutdown #914

Merged
merged 4 commits into from
Apr 17, 2023

Conversation

vladtr
Copy link
Contributor

@vladtr vladtr commented Mar 28, 2023

This PR adds command line option to leap-util to indicate if the last shutdown was clean or not. This would allow someone to better control logic about perhaps automatically starting from snapshot if the state database was crashed.

Examples of use:

Successful check with default state location:

./leap-util chain-state last-shutdown-state
Database state is clean

echo $?
0

Unsuccessful check with custom state path:

./leap-util chain-state last-shutdown-state --state-dir=/non-existent-dir
Unable to read database status: file not found: "/non-existent-dir/shared_memory.bin"

echo $?
255

After nodeos was killed with -9:

./leap-util chain-state last-shutdown-state
Database dirty flag is set, shutdown was not clean

echo $?
255

@vladtr vladtr marked this pull request as ready for review March 28, 2023 19:25
if(dbheader->dirty) {
std::cout << "Database dirty flag is set, shutdown was not clean" << std::endl;
return -1;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should check that dbheader's header_id is expected value, as it's possible the format will change in the future

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you, done

@heifner
Copy link
Member

heifner commented Mar 28, 2023

Can you add to the PR description details about the new option and an example of the output.

@heifner heifner added the documentation Improvements or additions to documentation label Mar 28, 2023
@spoonincode spoonincode self-requested a review April 4, 2023 01:18
@stephenpdeos stephenpdeos added this to the Leap v5.0.0-rc1 milestone Apr 12, 2023
@vladtr vladtr merged commit d849c9c into main Apr 17, 2023
@vladtr vladtr deleted the leaputil-shutdown-state branch April 17, 2023 18:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Add command line option to leap-util to indicate if the last shutdown was clean or not
5 participants