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

core/rawdb, eth, les,node: implemented update for unclean shutdown marker #22974

Closed
wants to merge 22 commits into from
Closed

core/rawdb, eth, les,node: implemented update for unclean shutdown marker #22974

wants to merge 22 commits into from

Conversation

BitBaseBit
Copy link

@BitBaseBit BitBaseBit commented May 31, 2021

Fixes #22580. As mentioned there, the unclean shutdown marker was using the initial boot time of the last know crash to report to the user that a crash had occurred. It would be more useful if the user know when the crash happened, instead of only knowing when the node was booted before it crashed. As discussed in #22580, the marker update time is set to 5 minutes. There is also a global in there that I know shouldn't be, my initial though was to put it in handler in the Ethereum struct, but I'm not sure that's appropriate.

@BitBaseBit
Copy link
Author

Seems like the CI build fail is unrelated to this PR, I can't reproduce the fail locally.

@karalabe
Copy link
Member

karalabe commented Jun 8, 2021

The PR is a good idea, but the problematic part is what you also mentioned in the code, that you have this dangling global channel to terminate the goroutine. We've discussed it a bit today that this mechanism might be better in the database layer, since "unclean shutdown" really means "was the db closed properly or not".

We think the best place we could add it would be core/rawdb/database.go (you might need to think it over a bit how best to add so both the "freezer" and "non freezer" dbs are covered). This way you can start the goroutine when the database is opened and terminate it when the database is closed, and instead of a dangling channel, you can keep it internal to the database fields.

@BitBaseBit
Copy link
Author

The PR is a good idea, but the problematic part is what you also mentioned in the code, that you have this dangling global channel to terminate the goroutine. We've discussed it a bit today that this mechanism might be better in the database layer, since "unclean shutdown" really means "was the db closed properly or not".

We think the best place we could add it would be core/rawdb/database.go (you might need to think it over a bit how best to add so both the "freezer" and "non freezer" dbs are covered). This way you can start the goroutine when the database is opened and terminate it when the database is closed, and instead of a dangling channel, you can keep it internal to the database fields.

Thanks for the feedback! I will make the suggested changes.

@BitBaseBit BitBaseBit requested a review from fjl as a code owner June 9, 2021 22:19
@BitBaseBit BitBaseBit requested a review from renaynay as a code owner June 9, 2021 22:19
@BitBaseBit
Copy link
Author

The PR is a good idea, but the problematic part is what you also mentioned in the code, that you have this dangling global channel to terminate the goroutine. We've discussed it a bit today that this mechanism might be better in the database layer, since "unclean shutdown" really means "was the db closed properly or not".

We think the best place we could add it would be core/rawdb/database.go (you might need to think it over a bit how best to add so both the "freezer" and "non freezer" dbs are covered). This way you can start the goroutine when the database is opened and terminate it when the database is closed, and instead of a dangling channel, you can keep it internal to the database fields.

I have implemented what you suggested.

@BitBaseBit BitBaseBit changed the title core/rawdb, eth, les: implemented update for unclean shutdown marker core/rawdb, eth, les,node: implemented update for unclean shutdown marker Jun 10, 2021
@holiman
Copy link
Contributor

holiman commented Jun 28, 2021

I pushed a commit to clean it up a bit -- using a switch instead of a sequence of if-clauses, and removing an unnecesary param. It's a little smaller now, easier to evaluate.
It's still not quite production ready though.

@jayboy-mabushi
Copy link

@BitBaseBit I am having this issue. How can I resolve it?

image

Copy link
Contributor

@holiman holiman left a comment

Choose a reason for hiding this comment

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

Huh, I made this comment a long++ time ago, but it got left in "Pending" -- I never actually submittted the review. Doh!

type nofreezedb struct {
ethdb.KeyValueStore
stopUncleanMarkerUpdateCh chan bool
isChainDb bool
Copy link
Contributor

Choose a reason for hiding this comment

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

This is very un-intuitive IMO. Would be better to have the channel be nil if it's not needed, instead of having a separate boolean on-the-side to tell whether it's used or not.

@s1na
Copy link
Contributor

s1na commented Jan 13, 2022

This PR was superseded by #24077. Closing.

@s1na s1na closed this Jan 13, 2022
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.

Update the unclean shutdown marker every 5 minutes
5 participants