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

[R4R]fix prefetcher related bugs #491

Merged
merged 2 commits into from
Nov 1, 2021
Merged

Conversation

keefel
Copy link
Contributor

@keefel keefel commented Oct 29, 2021

Description

1.Fix panic in trie_prefetcher close
2.Fix trie_prefetcher abortLoop goroutine leak

Rationale

1.In ValidateState, there are three goroutines running concurrently, if the previous one return error, the upper caller function InsertChain would return and call it's defer function to close prefetcher, while the IntermediateRoot goroutine still run and when it done call its defer function to close prefetcher, this time the prefetcher is nil, so it will trigger a panic. So we should wait all the goroutines done in ValidateState to avoid this panic.
2.In InsertChain, if we enable diffsync, and insert two more blocks here, then all the blocks except the last one wound't do call StopPrefetcher, so these blocks' abortLoop goroutine will leak. So we should do the StopPrefetcher in IntermediateRoot to avoid this leak.

Example

add an example CLI or API response...

Changes

Notable changes:

  • add each change in a bullet point here
  • ...

Preflight checks

  • build passed (make build)
  • tests passed (make test)
  • manual transaction test passed

Already reviewed by

...

Related issues

#477

@keefel keefel changed the title Bugfix fix prefetcher related bugs Oct 29, 2021
@@ -144,13 +144,15 @@ func (v *BlockValidator) ValidateState(block *types.Block, statedb *state.StateD
validateRes <- tmpFunc()
}()
}

var err error = nil
Copy link
Collaborator

Choose a reason for hiding this comment

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

var err error is enough

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@unclezoro unclezoro changed the title fix prefetcher related bugs [R4R]fix prefetcher related bugs Nov 1, 2021
Signed-off-by: Keefe-Liu <bianze.kernel@gmail.com>
Signed-off-by: Keefe-Liu <bianze.kernel@gmail.com>
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.

3 participants