Skip to content

Fix cache corruption due to CollectCacheGarbage call during GridReader/Async queries#2218

Open
aklein53 wants to merge 1 commit into
DapperLib:mainfrom
aklein53:fix/multimap-param-cache-poisoning
Open

Fix cache corruption due to CollectCacheGarbage call during GridReader/Async queries#2218
aklein53 wants to merge 1 commit into
DapperLib:mainfrom
aklein53:fix/multimap-param-cache-poisoning

Conversation

@aklein53

Copy link
Copy Markdown

This fixes a couple of issues where GetCacheInfo is called with null exampleParameters for an Identity that has non-null parameters. For example, deferred GridReader and async MultiMap calls do an initial call with non-null example parameters, and then do a second call with null example parameters. Usually this works fine because the cache entry is created in the first call with the correct reader and the second call results in a cache hit based on the Identity. However, with multiple concurrent Dapper calls happening at once, CollectCacheGarbage can sometimes be hit after the first GetCacheInfo call and before the second. This results in the second call (with null example parameters) creating a cache entry with a bad reader that breaks all future usages of that Identity until that entry is removed from the cache.

Fixes #1169

…exampleParameters for an Identity that has non-null parameters. For example, deferred GridReader and async MultiMap calls do an initial call with non-null example parameters, and then do a second call with null example parameters. Usually this works fine because the cache entry is created in the first call with the correct reader and the second call results in a cache hit based on the Identity. However, with multiple concurrent Dapper calls happening at once, CollectCacheGarbage can sometimes be hit after the first GetCacheInfo call and before the second. This results in the second call (with null example parameters) creating a cache entry with a bad reader that breaks all future usages of that Identity until that entry is removed from the cache.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dapper looses parameters

1 participant