-
Notifications
You must be signed in to change notification settings - Fork 86
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
Fix clean state initialization #3514
Conversation
1e9c1e8
to
2b39adc
Compare
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.
LGTM, but it'd like to go through this over a call.
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.
I agree that this does what we want, but I think there's a more suitable implementation; one that doesn't use a mutvar "unnecessarily".
I'm thinking something like:
llrnWithCheckedDB :: forall a. (LastShutDownWasClean -> m (a, ThisShutDownWasClean)) -> m a
Or maybe something like
llrnWithCheckedDB :: forall a. (LastShutDownWasClean -> (forall b. m b -> m b) -> m a) -> m a
Where the passes wrapper is applied to the continuation of initialization, and it's the part that removes the marker (if present) and installs the handler that writes it.
Let's chat about it.
0ffe572
to
173744c
Compare
3e61223
to
978924c
Compare
887aeef
to
1a72165
Compare
1a72165
to
51fea95
Compare
I amended your commit with a tiny change, just renaming
I squashed that into your commit and force-pushed it back up. |
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.
Looks great!
bors merge |
Build succeeded: |
Due to the unmasking of exceptions during ChainDB initialization, it is the case right now that the exit code is different from
DatabaseCorruption
and therefore thewithCheckedDb
function considers that it has to create the clean file. Because of this, a Ctrl+C during initialization would skip the validation on the next startup.This PR ensures that the clean file is only removed after the chainDB is initialized (and therefore potentially modified) and from that point on it can be created again.
SIGKILL
DatabaseCorruption
^C
)