Historian: Improve cache hits for specific summary shas #14624
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.
Description
Historian caches latest summary, but it doesn't check if a requested summary version is already cached as latest.
A bug in the R11s-driver was recently fixed in #14400 where the driver will request latest summary, then also request it again by its ID. This is fixed in the driver now, but will take some time to saturate clients using r11s-driver. We can lessen the impact of this bug on the server by causing that 2nd read to be a Cache Hit instead of a 100% miss.
Breaking Changes
None, but I removed a commented out section of code from #12036 and replaced it with a reference to an issue I opened to track it instead (#14623).
Reviewer Guidance
The goal here is to check if the requested summary sha is the same as the cached latest summary sha. However, we do not want to read the entire summary from cache into memory just to read its sha, in case it is not a cache hit. Instead, I added an additional cache key which will store specifically the cached latest summary's sha, which will improve efficiency of the sha equality check.