Repository navigation
Fix deferred HybridCache tag invalidation - #7786
Conversation
Use the cached payload creation timestamp when validating pending tag invalidations and cover the cross-node L2 race with a regression test. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Group successful payload parse outputs into a structured result to keep production and test call sites readable. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Copilot review overview
๐ก Changes recommended
The regression test does not deterministically exercise the deferred tag-check path.
Get a fresh assessment by requesting another Copilot review.
Review effort: Balanced
Findings: 1
Open (1)
What changed in this PR
Fixes deferred HybridCache tag invalidation by comparing against the cached payloadโs creation timestamp.
Changes:
- Groups parsed payload metadata into
ParsedPayload. - Uses payload creation time for deferred tag checks.
- Adds payload and shared-L2 regression coverage.
| File | Description |
|---|---|
HybridCachePayload.cs |
Returns structured parse results with creation time. |
DefaultHybridCache.StampedeStateT.cs |
Uses payload timestamp for deferred invalidation. |
PayloadTests.cs |
Updates parser tests for structured results. |
L2Tests.cs |
Adds a two-node invalidation regression test. |
๐ก Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
๐ Good job! The coverage increased ๐
Full code coverage report: https://dev.azure.com/dnceng-public/public/_build/results?buildId=1612268&view=codecoverage-tab |
Gate the tag read while returning the entry synchronously so payload parsing must reach the deferred pending-tag check before the test releases it. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Rename the wrapped distributed cache from tail to inner in the regression test helper. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Copilot review overview
๐ข Approval recommended
The fix correctly addresses the stale-read defect with focused regression coverage; the remaining comment typo is non-blocking.
Review effort: Balanced
Findings: 1
Open (1)
Resolved since last review (1)
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
๐ Good job! The coverage increased ๐
Full code coverage report: https://dev.azure.com/dnceng-public/public/_build/results?buildId=1612414&view=codecoverage-tab |
rosebyte
left a comment
There was a problem hiding this comment.
I guess you benchmarked the passing of the large struct through the out parameter, so LGTM.
Microsoft.Extensions.Caching.Hybrid 10.10.0 validates a payload tag whose invalidation marker is still loading against the reader's start time, not the payload's creation time, and skips a wildcard marker that is still loading (fixed upstream in dotnet/extensions#7786, not yet released). A new context could therefore return an L2 entry that had already been removed by tag when its own marker read completed after the payload read. Tag propagation relies on new contexts (per-request fallbacks and new observations) to reload authoritative tag metadata, so it hit this race under load. Read the request tags' and the wildcard's markers first and replay them into the context, keeping a newer remembered invalidation. This is the cause of the intermittent "old" results in SubscriberReconnectDropsCachedTagMetadataAcrossAMissedInvalidation.


Summary
Fixes #7771