-
Notifications
You must be signed in to change notification settings - Fork 14k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(key-value): add superset metastore cache #19232
Conversation
0f76444
to
a835e9c
Compare
7c2d53d
to
d4338b9
Compare
superset-frontend/cypress-base/cypress/integration/dashboard/key_value.test.ts
Outdated
Show resolved
Hide resolved
with freeze_time(dttm): | ||
cache.set(FIRST_KEY, FIRST_KEY_INITIAL_VALUE, int(delta.total_seconds())) | ||
assert cache.get(FIRST_KEY) == FIRST_KEY_INITIAL_VALUE | ||
with freeze_time(dttm + delta - timedelta(seconds=1)): | ||
assert cache.has(FIRST_KEY) | ||
assert cache.get(FIRST_KEY) == FIRST_KEY_INITIAL_VALUE | ||
with freeze_time(dttm + delta + timedelta(seconds=1)): | ||
assert cache.has(FIRST_KEY) is False | ||
assert cache.get(FIRST_KEY) is None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Btw I truly LOVE freeze_time
! ❤️
Codecov Report
@@ Coverage Diff @@
## master #19232 +/- ##
==========================================
+ Coverage 66.53% 66.59% +0.05%
==========================================
Files 1667 1670 +3
Lines 64360 64501 +141
Branches 6493 6493
==========================================
+ Hits 42824 42952 +128
- Misses 19854 19867 +13
Partials 1682 1682
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
/testenv up |
@villebro Ephemeral environment spinning up at http://35.87.132.23:8080. Credentials are |
I can confirm that the dashboard and explore ephemeral env now work as intended by defaulting to the new cache |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work! I'm still a little hesitant on conflating caching and persistent storage (the semantics are just so different), but this does seem to be an improvement to status quo, so I'll vote yes on this change.
superset/key_value/cache.py
Outdated
from superset.key_value.types import KeyType | ||
|
||
RESOURCE = "superset_cache" | ||
KEY_TYPE: KeyType = "uuid" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Linking my previous comment about KeyType in case you missed it: #19078 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks - many good comments there - I'll be opening a follow-up PR to address those!
@ktmud I believe I've addressed all your comments |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks for the improvement!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks for the updates!
Ephemeral environment shutdown and build artifacts deleted. |
(cherry picked from commit 72b9a7f)
SUMMARY
Add custom
Flask-Caching
backend that leverages the newkey_value
table that was introduced in #19078. This makes it possible to use the metadata database as a cache. Superset defaults to the new cache for required caches that have not been defined in the configs. This is to reintroduce support for multi-pod deployments that don't have a dedicated cache.The cache implements all cache methods that are used in the application (
add
,set
,get
,has
,delete
), and can be used as a caching backend for any purpose. For instance, to use it to store chart data, the following can be added tosuperset_config.py
:In addition, Explore form data/Dashboard filter state caches in the ephemeral environments are currently failing on master - after this gets merged they should now work as intended, as they'll use this cache.
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
TESTING INSTRUCTIONS
ADDITIONAL INFORMATION