apache/superset · error · ChartDataCacheLoadError
Cached data not found
Error message
Cached data not found
What it means
QueryContextCacheLoader.load() raises ChartDataCacheLoadError("Cached data not found") when superset's shared cache returns a falsy value for the given cache_key. This loader is the retrieval half of the chart-data 'cache as payload' flow (used by async queries and force_cached requests), where an entire QueryContext payload is stored under one key. A miss means the key expired, was evicted, the cache backend was flushed/restarted, or the key was computed against a different cache config.
Source
Thrown at superset/charts/data/query_context_cache_loader.py:28
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
from typing import Any
from superset import cache
from superset.commands.chart.exceptions import ChartDataCacheLoadError
class QueryContextCacheLoader: # pylint: disable=too-few-public-methods
@staticmethod
def load(cache_key: str) -> dict[str, Any]:
cache_value = cache.get(cache_key)
if not cache_value:
raise ChartDataCacheLoadError("Cached data not found")
return cache_value["data"]
View on GitHub (pinned to f4587218dd)
Solutions
- Re-run the query without force_cached so a fresh payload is computed and re-cached.
- Raise or remove the TTL/eviction limits on the cache backend used by ChartDataAsyncQueryRestApi (CACHE_CONFIG / FEATURE_FLAG async queries) so results survive until fetched.
- Ensure all nodes share the same cache backend (Redis) and the same Superset version so cache keys hash identically.
- Check for cache flushes or Redis maxmemory evictions (INFO stats: evicted_keys) if misses are frequent.
Example fix
# before
from superset.charts.data.query_context_cache_loader import QueryContextCacheLoader
data = QueryContextCacheLoader.load(cache_key)
# after
from superset.commands.chart.exceptions import ChartDataCacheLoadError
from superset.charts.data.query_context_cache_loader import QueryContextCacheLoader
try:
data = QueryContextCacheLoader.load(cache_key)
except ChartDataCacheLoadError:
data = reexecute_query_and_cache() # fall back to a fresh run Defensive patterns
Strategy: fallback
Validate before calling
from superset import cache
def cache_entry_exists(cache_key: str) -> bool:
return bool(cache.get(cache_key)) Try / catch
from superset.commands.chart.exceptions import ChartDataCacheLoadError
from superset.charts.data.query_context_cache_loader import QueryContextCacheLoader
try:
data = QueryContextCacheLoader.load(cache_key)
except ChartDataCacheLoadError:
data = reexecute_query_and_store(cache_key) Prevention
- Set the chart-data cache TTL longer than the maximum expected time between query submission and result pickup.
- Use a shared, durable Redis cache for async queries across all workers/replicas.
- Keep Superset versions uniform across nodes so cache keys are computed identically.
When it happens
Trigger: Calling ChartDataAsyncQueryRestApi result retrieval after the cached entry TTL expired; GET /api/v1/chart/data/<cache_key> style flows where the cache key was generated by a different worker with different CACHE_CONFIG or a different Superset version (key hashing changed); Redis/memcached restart or FLUSHDB between query submission and result pickup; force_cached=True with an expired key.
Common situations: Multi-worker or multi-node deployments where nodes disagree on cache key generation; CACHE_CONFIG TTL shorter than long-running queries; upgrading Superset versions that change query context serialization, invalidating old keys; local dev with in-memory cache restarted between submit and fetch.
Related errors
- Error loading data from cache
- Unsupported cache backend configuration
- Cache backends (CACHE_CONFIG, DATA_CACHE_CONFIG) must be con
- Received unexpected response status (${response.status}) whi
- Received unexpected response status (${response.status}) whi
AI-assisted analysis of apache/superset@f4587218dd (2026-08-14).
Data as JSON: /api/errors/a2d13becd0d9b7e5.
Report an issue: GitHub.