Repository navigation
Conversation
MultiMapAsync calls GetCacheInfo to setup the command and parameter reader. It then delegated to MultiMapImpl, which performed a redundant GetCacheInfo call for the same identity. Because GetCacheInfo records a cache hit on finding an existing entry, a single-execution async multi-map query ended up with hitCount = 1 instead of 0, preventing garbage collection by CollectCacheGarbage and causing one-off queries to linger in the cache. Pass the already resolved CacheInfo into MultiMapImpl so the first execution retains hitCount = 0 and normal cache cleanup can collect unreused queries. Fixes DapperLib#2240
This branch has not been deployed
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.
Description
Fixes #2240
When executing an asynchronous multi-map query (\MultiMapAsync), Dapper calls \GetCacheInfo(identity, param, command.AddToCache)\ to resolve the parameter reader and set up the command. It then delegated to \MultiMapImpl, which performed a second call to \GetCacheInfo\ for the same identity without passing the already-resolved \CacheInfo.
Because \GetCacheInfo\ invokes \RecordHit()\ upon finding an existing cache entry (\TryGetQueryCache), this second internal lookup caused the very first execution of an async multi-map query to record a hit count of 1 rather than 0.
As reported in #2240, because \CollectCacheGarbage\ collects entries with \hitCount <= 0, queries executed once via \MultiMapAsync\ survived cache garbage collection, which could accumulate one-off/interpolated multi-map queries over time.
Changes
Verification
et8.0,
et10.0,
etstandard2.0,
et461, etc.).
et8.0\ and
et10.0.