Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Caching): Correct Cancellation Handling #451

Merged
merged 2 commits into from
Apr 8, 2024
Merged

Conversation

bartelink
Copy link
Collaborator

@bartelink bartelink commented Apr 8, 2024

Where the request being processed via the read through cache mechanism gets Cancelled (via CancellationTokenSource, but also via things like Async.Parallel's cancellation of sibling requests), the Task held within the LazyTask ends up in Cancelled state, not the more typical IsFaulted.

This leads to incorrect re-use of the cached value (as held within the cell).

This in turn leads to any request with AnyCachedValue (or AllowStale) in 4.0.0 failing with TaskCancelledException for as long as that cache entry lives.


While this is a relatively obvious mistake, the issue is only reproducable with very heavy parallism - and it's only in cache read through mode (allowStale > TimeSpan.Zero) that this comes into play.

@bartelink bartelink changed the title fix(Caching): Handle cancellation fix(Caching): Fix cancellation handling Apr 8, 2024
@bartelink bartelink changed the title fix(Caching): Fix cancellation handling fix(Caching): Correct Cancellation Handling Apr 8, 2024
@bartelink bartelink changed the base branch from master to cosmos-conn April 8, 2024 21:33
@bartelink bartelink changed the base branch from cosmos-conn to master April 8, 2024 21:34
@bartelink bartelink merged commit 4aab4a2 into master Apr 8, 2024
5 checks passed
@bartelink bartelink deleted the fix-cancellation branch April 8, 2024 21:58
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.

1 participant