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

Dump the block validation cache whenever we perform an import #4287

Merged
merged 4 commits into from
Oct 10, 2020

Conversation

ribasushi
Copy link
Contributor

This solves (tested on multiple runs) a problem with folks resurrecting long-out-of-sync nodes via
snapshot imports.

The interface switch to Batching is necessary: startup is too long otherwise
( 8 minutes just to clear everything on a relatively old node )

This solves a problem with folks resurrecting long-out-of-sync nodes via
snapshot imports.

The interface switch to Batching is necessary: startup is too long otherwise
( 8 minutes just to clear everything on a relatively old node )
func (cs *ChainStore) FlushValidationCache() error {
log.Infof("clearing block validation cache...")

dsWalk, err := cs.ds.Query(query.Query{KeysOnly: true})
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
dsWalk, err := cs.ds.Query(query.Query{KeysOnly: true})
dsWalk, err := cs.ds.Query(query.Query{KeysOnly: true, Prefix: blockValidationCacheKeyPrefix.String()})

Then we should be able to drop the prefix check below

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Prefix won't work :(
Prefix is for foo/bar, it doesn't work for foo:bar which is how we assemble the validation cache via .Instance higher up

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@magik6k added a comment to clarify why things are the way they are: 23f5a99

@jsign
Copy link
Contributor

jsign commented Oct 10, 2020

Tested this PR to see if fixes the importing problem, it does!

BTW:

2020-10-10T14:54:10.225Z        INFO    chainstore      store/store.go:455      clearing block validation cache...
2020-10-10T14:54:11.216Z        INFO    chainstore      store/store.go:494      224149 block validation entries cleared.

So this cache clearing is very fast. Complete importing is 8 min.

Looking forward to see this merged, I'd like to nuke >20 Lotus nodes datastore/chain folder with a fresh snapshot. :)

@magik6k magik6k merged commit 151577f into master Oct 10, 2020
@magik6k magik6k deleted the feat/flush_validation_cache_on_chain_import branch October 10, 2020 18:33
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.

None yet

3 participants