Cache: Add awaits to memory cache rebuilds to fix race conditions#20960
Merged
AndyButland merged 2 commits intomainfrom Nov 26, 2025
Merged
Cache: Add awaits to memory cache rebuilds to fix race conditions#20960AndyButland merged 2 commits intomainfrom
AndyButland merged 2 commits intomainfrom
Conversation
AndyButland
approved these changes
Nov 26, 2025
Contributor
AndyButland
left a comment
There was a problem hiding this comment.
I think I can review and approve this with just visual inspection, as it's clearly an existing oversight and a correct update.
Contributor
Author
|
Cherry picked for 17.0.1 🚀 |
This was referenced Dec 8, 2025
Closed
Bump Umbraco.Cms.Persistence.EFCore from 17.0.0 to 17.0.1
karl-sjogren/umbraco-extend-everything#134
Closed
Merged
This was referenced Jan 26, 2026
This was referenced Feb 23, 2026
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.
What does this PR fix?
This PR adds missing
awaitkeywords on async cache operations that were introduced in #17296.Context
With the introduction of hybrid cache rebuilding, memory cache was added to cache refreshers in #17296. During this process, awaits were missed on async methods (see this example), meaning the run in parallel, which can't work.
This has caused race conditions which can result in various issues such as multiple open DataReaders and failure to acquire locks.
This issue becomes particularly apparent when adding an L2 cache like Redis, likely because
hybridCache.RemoveAsyncbecomes truly asynchronous in that scenario. Additionally, this issue only affects SQL Server.Testing
Due to the nature of race conditions, this is difficult to test reliably. However, the issue can be reproduced consistently by:
Redis cache configuration example:
Install
Microsoft.Extensions.Caching.StackExchangeRedis