Repository navigation
Conversation
Adds an opt-in CACHE_WARMUP_ON_LOGIN setting. After a successful login an asynchronous Celery task runs as the user and computes only the missing or expired chart query results for their most recently favorited dashboards. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
✅ Deploy Preview for superset-docs-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Replaces the login-triggered warm-up with a beat-scheduled `favorites` strategy for the cache-warmup task. It enqueues one task per recently active user that warms only missing or expired results on their favorited dashboards, with a per-result lock, dashboard cap, optional dedicated queue and a task time limit. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…docs Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #45873 +/- ##
===========================================
+ Coverage 65.62% 84.70% +19.08%
===========================================
Files 3069 3069
Lines 205661 205788 +127
Branches 48336 48357 +21
===========================================
+ Hits 134956 174315 +39359
+ Misses 67624 28174 -39450
- Partials 3081 3299 +218
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:
|
This branch has not been deployed
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.
SUMMARY
Adds a
favoritesstrategy to the existingcache-warmupCelery beat task. On each scheduled run it picks recently active users who have favorited dashboards and warms the charts on those dashboards, so their favorites load from cache. It is gated by theCACHE_WARMUP_FAVORITESconfig setting (defaultFalse; not a feature flag) and runs only when an operator schedules it.A chart is only computed if its cached result is missing or expired; charts that are already cached are left alone, so no queries are repeated needlessly.
Design notes:
SUPERSET_CACHE_WARMUP_USER, because cache keys depend on the requesting user (row-level security, per-user caching, impersonation). Access to each dashboard and chart is checked for that user.ChartWarmUpCacheCommand. A newonly_if_staleoption makes it look up the data cache first and fill misses without bypassing the cache. The existing "always force refresh" behavior is unchanged when the option is not used.max_usersandsinceon the strategy (most recent login first) andCACHE_WARMUP_FAVORITES_MAX_DASHBOARDS(default 5, newest favorites first) limit work per run. A per-result lock stops overlapping runs from computing the same result twice, and each per-user task has a 15 minute time limit and queued tasks expire after two hours. Favorites read per user are bounded in SQL. There is no per-user cooldown: the beat schedule is the throttle.CACHE_WARMUP_FAVORITES_QUEUE(defaultNone) can route these tasks to a dedicated queue so they do not compete with reports, alerts, or thumbnails.DATA_CACHE_CONFIGbackend.Example schedule:
TESTING INSTRUCTIONS
Unit tests:
pytest tests/unit_tests/tasks/test_cache.py tests/unit_tests/commands/chartManual: configure Redis for
DATA_CACHE_CONFIGandCACHE_CONFIG, run a Celery worker and beat with the schedule above andCACHE_WARMUP_FAVORITES = True. Favorite a dashboard as a user who has logged in recently, clear its cache, and confirm the worker computes its charts on the next run and computes nothing on a later run while the cache is warm.ADDITIONAL INFORMATION
🤖 Generated with Claude Code