Open
Conversation
fa70582 to
abcc0ce
Compare
1b04ec4 to
dda2351
Compare
phbnf
approved these changes
Mar 27, 2026
dda2351 to
7ad6e13
Compare
roger2hk
reviewed
Mar 27, 2026
| // the tile containing the requested node will be fetched and cached, and the | ||
| // node hash returned. | ||
| // The tile containing the node will be fetched if necessary. | ||
| func (n *nodeCache) GetNode(ctx context.Context, id compact.NodeID) ([]byte, error) { |
Contributor
There was a problem hiding this comment.
There is a race condition in GetNode() when the LRU cache is full.
Scenario:
- The first goroutine calls
GetNode(). It's a cache miss, then the goroutine fetches the tile and add the node to the LRU cache. - Meanwhile, there are many other goroutines fetching other tiles and adding the nodes into the LRU cache.
- The LRU cache is full and evicts the node from the first goroutine.
- The first goroutine tries to call
n.nodes.Get(id);and couldn't find the node. - The unexpected error
internal error: missing node %+vis returned.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR improves the implementation of the node cache under
client.With these changes,
nodeCacheis now thread-safe, and supports concurrent fetching of arbitrary nodes, potentially speeding up the process of building trees and proofs if the underlying storage has high latency.Towards #892