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

redis force-reconnect; fix release failure scenario #52608

Merged
merged 1 commit into from
Dec 7, 2023

Conversation

mgravell
Copy link
Member

@mgravell mgravell commented Dec 6, 2023

nit bugfix; redis caching with "force reconnect" enabled (feature flag) resets the connection in some error scenarios; it does this with a CompareExchange, but incorrectly it releases the result of this (the old value of _cache) irrespective of the outcome; it should test whether this was what we expected, and only release the connection if we have actively wiped the connection

problematic scenario (impossible to reproduce on demand):

  • cache is snapshotted as a non-null value
  • another thread swaps the connection
  • we get to the compare-exchange, which is a no-op because _cache isn't still the same reference as we hold in cache
  • we then release the active connection that we have no knowledge of

with the fix, we capture the response of CompareExchange and only release the connection if it matches the value we were thinking of, i.e. we have successfully swapped the connection out to null

@mgravell mgravell added the feature-caching Includes: StackExchangeRedis and SqlServer distributed caches label Dec 6, 2023
@dotnet-issue-labeler dotnet-issue-labeler bot added the area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions label Dec 6, 2023
Copy link
Member

@amcasey amcasey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops.

@amcasey amcasey added the area-middleware Includes: URL rewrite, redirect, response cache/compression, session, and other general middlewares label Dec 6, 2023
@adityamandaleeka
Copy link
Member

Should this go into 8.0 servicing as well?

@mgravell
Copy link
Member Author

mgravell commented Dec 7, 2023

@adityamandaleeka might as well, as a minor bugfix; I'll kick off a backport

@mgravell mgravell merged commit fe7bc0f into main Dec 7, 2023
@mgravell mgravell deleted the marc/fix-force-reconnect branch December 7, 2023 14:15
@ghost ghost added this to the 9.0-preview1 milestone Dec 7, 2023
@adityamandaleeka
Copy link
Member

@mgravell sounds good. You should be able to use the bot to backport.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-middleware Includes: URL rewrite, redirect, response cache/compression, session, and other general middlewares area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions feature-caching Includes: StackExchangeRedis and SqlServer distributed caches
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants