Repository navigation
fix(semantic-cache): forced queries store their fresh result - #41826
mikebridge wants to merge 2 commits into
Conversation
_make_cached_dispatch returned the raw dispatcher on force_query, bypassing both the cache READ and store_result — so a forced refresh never replaced the stale containment-cache entry, and other requests' contained lookups kept serving it until TTL or invalidation. The remaining half of the bug shape fixed for the DATA cache in the force_query/cache_key PR. Forced queries now skip only the read and store the fresh result; row-count queries still bypass entirely. The existing force test is rewritten to the full contract: forced execution happens, AND a subsequent ordinary request is served from cache with the REFRESHED value — validated to fail against the pre-fix mapper.
|
Bito Automatic Review Skipped - Branch Excluded |
✅ Deploy Preview for superset-docs-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## sl-cache #41826 +/- ##
==========================================
Coverage 63.43% 63.43%
==========================================
Files 2592 2591 -1
Lines 138780 138647 -133
Branches 32235 32214 -21
==========================================
- Hits 88038 87955 -83
+ Misses 49212 49171 -41
+ Partials 1530 1521 -9
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Review-panel finding on the sibling force-store PR (apache#41826): candidates were ranked by reuse mode only, and Python's stable sort preserves insertion order within a rank — so an OLDER stale broader entry that also satisfies the query (EXACT-with-leftovers) was served ahead of a just-forced fresh entry for the identical query. The forced refresh never stuck for readers. Tie-break by entry timestamp, freshest first. Pinned by a test with a deterministically older same-rank broader entry — fails under the rank-only sort.
Review-panel finding (4/4 lenses): the docstring promised a forced refresh 'replaces the stale entry that other requests' containment lookups keep reading' — true only for the same canonical shape. Broader stale entries are out of a narrower forced result's reach by design and age out by TTL; the freshest-first ranking (added in the sibling index PR) is what makes the refreshed entry win for the identical query. Also clarified the test's mock-swap counter-reset subtlety.
|
Round-2 review (four-lens panel via Claude, findings verified): 4/4 approve, 0 blockers. Resolutions pushed:
Panel also verified: forced stores are shape-safe (the stored entry is exactly what a cold miss would write), the payload overwrite survives #41824's lock-skip path (the |
rusackas
left a comment
There was a problem hiding this comment.
LGTM, thanks for chasing down the other half of this. The test proving it fails against the pre-fix mapper is a nice touch.
One thing I'm curious about, not blocking: could a slower concurrent ordinary query land after the forced write and clobber it with a stale result? Feels like a property of the general cache design rather than something new here.
|
Supersession note to prevent accidental merge: #42760 is the consolidated replacement under review and explicitly carries forward the still-valid work and attribution from this PR stack. This does not mean #42760 has been accepted for adoption yet; that decision remains pending. Please do not merge this stacked PR while the consolidation decision is open; a maintainer or PR owner can close it and reopen later if the direction changes. |
|
Same situation as |
|
Closing: this was a contribution into #40221's Closed by Claude (AI) on behalf of @mikebridge. |
SUMMARY
Third contribution into #40221's branch (
sl-cache) — the remaining half of the force-refresh bug shape fixed in #41825:_make_cached_dispatchreturned the raw dispatcher whenforce_querywas set, bypassing both the cache read andstore_result. Consequence: a forced refresh executed fresh but never replaced the stale containment-cache entry — other requests whose queries were contained by that stale entry kept being served from it until TTL or a view-definition change. (#41825 fixed the same shape at the DATA-cache layer; this fixes it at the semantic layer.)The fix: forced queries skip only the cache read and still store their fresh result; row-count queries continue to bypass entirely.
TESTING INSTRUCTIONS
The existing force test is rewritten to pin the full contract: the forced query re-executes, and a subsequent ordinary request is served from cache with the refreshed value rather than the stale one — validated to fail against the pre-fix mapper.
pytest tests/unit_tests/semantic_layers/cache_integration_test.py -q # 15 passedADDITIONAL INFORMATION
🤖 Generated with Claude Code