Skip to content

fix(query-object): exclude force_query from the chart cache key - #41825

Closed
mikebridge wants to merge 2 commits into
apache:sl-cachefrom
mikebridge:pr-40221-force-query-cache-key
Closed

mikebridge wants to merge 2 commits into
apache:sl-cachefrom
mikebridge:pr-40221-force-query-cache-key

Conversation

@mikebridge

@mikebridge mikebridge commented Jul 6, 2026 •

Copy link
Copy Markdown
Member

SUMMARY

Second contribution into #40221's branch (sl-cache), fixing the unaddressed codeant architect finding on query_object.py (2026-05-19) — verified real:

force_query was added to QueryObject for the semantic cache's bypass check (legitimate), but it also landed in to_dict(), which cache_key() hashes. An execution-control flag inside the identity hash means:

  1. A user's force refresh writes its fresh result under a different cache key (force_query=True hashed in).
  2. Every subsequent ordinary request hashes force_query=False → keeps serving the stale entry under the old key. Force-refresh silently stops refreshing what other viewers see, and cache storage doubles per chart.

This affects every chart on the legacy path, not just semantic layers.

The fix: strip force_query in cache_key(), exactly like the existing execution-control exclusions two lines above (from_dttm/to_dttm, conditional apply_fetch_values_predicate).

TESTING INSTRUCTIONS

test_cache_key_ignores_force_query pins that forced and unforced requests share a cache key — validated to fail without the fix.

The flag's bypass behaviour (as opposed to key identity) is separately pinned upstream in the stack: the semantic path reads the attribute directly (mapper.py) and is covered by test_force_query_bypasses_semantic_cache in cache_integration_test.py; the classic chart-cache bypass is likewise attribute-driven via QueryCacheManager.

pytest tests/unit_tests/queries/query_object_test.py -q   # 13 passed

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
  • Introduces new feature or API
  • Removes existing feature or API

🤖 Generated with Claude Code

force_query was added to QueryObject (for the semantic-layer cache's
bypass check) and included in to_dict() — which cache_key() hashes. An
execution-control flag in the identity hash means a forced refresh
writes its fresh result under a DIFFERENT cache key while every
subsequent ordinary request keeps reading the stale entry under the old
one: force-refresh becomes ineffective for all other viewers of the
chart, and cache storage doubles per chart. Affects every chart on the
legacy path, not just semantic layers.

Strip it in cache_key() alongside the existing execution-control
exclusions (from_dttm/to_dttm, conditional apply_fetch_values_predicate).
Verified surfaced by the codeant architect scan on apache#40221 (2026-05-19,
unaddressed). Test pins that forced and unforced requests share a cache
key; validated to fail without the fix.
@dosubot dosubot Bot added the infra:caching Infra setup and configuration related to caching label Jul 6, 2026
@bito-code-review

bito-code-review Bot commented Jul 6, 2026 •

Copy link
Copy Markdown
Contributor

Bito Automatic Review Skipped - Branch Excluded

Bito didn't auto-review because the source or target branch is excluded from automatic reviews.
No action is needed if you didn't intend for the agent to review it. Otherwise, to manually trigger a review, type /review in a comment and save.
You can change the branch exclusion settings here, or contact your Bito workspace admin at [email protected].

@netlify

netlify Bot commented Jul 6, 2026

Copy link
Copy Markdown

✅ Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit dbe2d06
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6a4c24f1b299250008e09f92
😎 Deploy Preview https://deploy-preview-41825--superset-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

…gration block

Review-panel finding (3/4 lenses): the exclusion sat inside the block
whose TODO says everything below it should eventually move INTO
to_dict() and be hashed — the exact opposite of force_query's contract.
Grouped with the from_dttm/to_dttm deletions instead, under an explicit
PERMANENT-exclusions comment. Test strengthened with a discrimination
guard (identity fields must still vary the key) and its docstring
deduplicated against the production comment.
@codecov

codecov Bot commented Jul 6, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 63.43%. Comparing base (5581315) to head (956d561).

Additional details and impacted files
@@            Coverage Diff             @@
##           sl-cache   #41825    +/-   ##
==========================================
  Coverage     63.43%   63.43%            
==========================================
  Files          2592     2591     -1     
  Lines        138780   138646   -134     
  Branches      32235    32214    -21     
==========================================
- Hits          88038    87955    -83     
+ Misses        49212    49170    -42     
+ Partials       1530     1521     -9     
Flag Coverage Δ
hive 39.23% <0.00%> (-0.02%) ⬇️
mysql 58.79% <100.00%> (-0.01%) ⬇️
postgres 58.86% <100.00%> (-0.01%) ⬇️
presto 40.92% <100.00%> (-0.02%) ⬇️
python 59.10% <100.00%> (-0.01%) ⬇️
sqlite 58.51% <100.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@rusackas rusackas left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, nice catch. force_query still gets checked directly in mapper.py for the semantic-cache bypass, so this only tightens the classic QueryObject.cache_key() hash without touching that path.

Red CI here is just the semantic_layers coverage gap, looks like #41856's already got it covered.

@mikebridge

Copy link
Copy Markdown
Member Author

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.

@rusackas

Copy link
Copy Markdown
Member

This has been idle since the supersession note was posted three weeks back. Has the call been made on #42760's consolidation? unit-tests is still red here too, so it isn't mergeable as-is regardless.

@mikebridge

Copy link
Copy Markdown
Member Author

Closing: this was a contribution into #40221's sl-cache branch, and #42760 has since replaced that branch as the semantic-layer containment cache. #42760 retains this fix — force_query is excluded from the ordinary result identity (QueryObject.cache_key pops it) — see the "Superseded PR → contribution retained" table in its description. Nothing further is needed on this PR.

Closed by Claude (AI) on behalf of @mikebridge.

@mikebridge mikebridge closed this Aug 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

infra:caching Infra setup and configuration related to caching size/S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants