Store permanent values in the cache (for #1683)#1685
Merged
hawkw merged 5 commits intoeliza/generalize-cachefrom May 19, 2022
Merged
Store permanent values in the cache (for #1683)#1685hawkw merged 5 commits intoeliza/generalize-cachefrom
hawkw merged 5 commits intoeliza/generalize-cachefrom
Conversation
In some cases--like inbound policy discovery--we have a set of permanent values that should never be removed from the cache. This change updates the cache to only hold a handle when eviction is scheduled. No handle is held when the cache entry is permanent. This change also fixes a possible race condition. Previously, the eviction task could consume an entry's handle without locking the cache. This made it possible for a `get_or_insert_with` call to race against the eviction task, adding an entry that would be immediately evicted by the eviction task. Signed-off-by: Oliver Gould <[email protected]>
Contributor
|
Oh, whoops, I missed this and made my own almost-identical version of the permanent entry part of the change: 3525055 I'm going to merge this anyway to pick up the race fix --- good catch. |
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.
In some cases--like inbound policy discovery--we have a set of permanent
values that should never be removed from the cache. This change updates
the cache to only hold a handle when eviction is scheduled. No handle is
held when the cache entry is permanent.
This change also fixes a possible race condition. Previously, the
eviction task could consume an entry's handle without locking the cache.
This made it possible for a
get_or_insert_withcall to race againstthe eviction task, adding an entry that would be immediately evicted by
the eviction task.
Signed-off-by: Oliver Gould [email protected]