Improve request graph cache reading #9721
Merged
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.
One of the issues that we think might be causing the cache related bugs we've been getting is that when reading the nodes files back in, the read and deserialise logic just reads in however many there happen to be on disk.
Since it's possible for two different instances of a RequestTracker to have the same cache key, and that one may contain fewer nodes, a number of incorrect nodes are being read in when we hydrate from cache.
To work around this, we're adding some information to the cache to store how many node chunk files there are and how many nodes are in each one. This avoids overreading from cache, and means we can validate that the right number of nodes are being read in (since the last file in a cache won't be full).
Also to allow for testing of multiple chunks, we've made the number of nodes that go in each blob a property on the class, so it can be overridden in testing (without having to create 2**16 test nodes to force a second chunk).