{"record":{"id":"761285cfc393fc56","repo":"apache/superset","slug":"error-loading-data-from-cache","errorCode":null,"errorMessage":"Error loading data from cache","messagePattern":"Error loading data from cache","errorType":"exception","errorClass":"ChartDataCacheLoadError","httpStatus":422,"severity":"error","filePath":"superset/commands/chart/data/get_data_command.py","lineNumber":51,"sourceCode":"\n\nclass ChartDataCommand(BaseCommand):\n    _query_context: QueryContext\n\n    def __init__(self, query_context: QueryContext):\n        self._query_context = query_context\n\n    def run(self, **kwargs: Any) -> dict[str, Any]:\n        # caching is handled in query_context.get_df_payload\n        # (also evals `force` property)\n        cache_query_context = kwargs.get(\"cache\", False)\n        force_cached = kwargs.get(\"force_cached\", False)\n        try:\n            payload = self._query_context.get_payload(\n                cache_query_context=cache_query_context, force_cached=force_cached\n            )\n        except CacheLoadError as ex:\n            raise ChartDataCacheLoadError(ex.message) from ex\n\n        # Skip error check for query-only requests - errors are returned in payload\n        # This allows View Query modal to display validation errors\n        for query in payload[\"queries\"]:\n            if (\n                query.get(\"error\")\n                and self._query_context.result_type != ChartDataResultType.QUERY\n            ):\n                raise ChartDataQueryFailedError(\n                    _(\"Error: %(error)s\", error=query[\"error\"])\n                )\n\n        return_value = {\n            \"query_context\": self._query_context,\n            \"queries\": payload[\"queries\"],\n        }\n        if cache_query_context:\n            return_value.update(cache_key=payload[\"cache_key\"])","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/apache/superset/blob/f4587218dd19d046c3e4d00063e7d27f8a2ed354/superset/commands/chart/data/get_data_command.py#L33-L69","documentation":"ChartDataCacheLoadError (CommandException) raised in ChartDataCommand.run() (get_data_command.py:51) when query_context.get_payload() signals CacheLoadError — the stored async-query payload for the computed cache key could not be loaded. The underlying message (e.g. 'Cached data not found') is passed through and the original exception chained. Typical of force_cached=True requests hitting an expired/evicted entry.","triggerScenarios":"POST /api/v1/chart/data with force_cached=true after the cached result TTL'd out or Redis evicted it; async query result pickup where the cache key was written by a node with different config; cache backend flushed between query and fetch.","commonSituations":"Long-running dashboards with short cache TTLs; rolling upgrades changing cache-key derivation; multi-node setups without a shared cache; Redis maxmemory eviction under load.","solutions":["Retry the request without force_cached (or with force: true) to recompute and refresh the cache.","Increase the cache TTL / capacity for the chart-data cache config so entries survive until read.","Point all nodes at one shared Redis and keep Superset versions aligned so keys match."],"exampleFix":"# before\npayload = ChartDataCommand(qc).run(cache=True, force_cached=True)\n\n# after\ntry:\n    payload = ChartDataCommand(qc).run(cache=True, force_cached=True)\nexcept ChartDataCacheLoadError:\n    payload = ChartDataCommand(qc).run(cache=True)  # recompute fresh","handlingStrategy":"fallback","validationCode":"from superset import cache\n\ndef can_load_cached(cache_key: str) -> bool:\n    return bool(cache.get(cache_key))\n\nif force_cached and not can_load_cached(cache_key):\n    force_cached = False  # recompute instead of failing","typeGuard":null,"tryCatchPattern":"try:\n    payload = ChartDataCommand(qc).run(cache=use_cache, force_cached=True)\nexcept ChartDataCacheLoadError:\n    payload = ChartDataCommand(qc).run(cache=use_cache)  # fresh recompute","preventionTips":["Keep chart-data cache TTL above the expected read-back window.","Share one Redis across replicas and keep versions aligned for stable cache keys.","Monitor evicted_keys; capacity-plan the cache for dashboard burst load."],"tags":["chart-data","cache","async","force-cached"],"backgroundTag":null,"analyzedSha":"f4587218dd19d046c3e4d00063e7d27f8a2ed354","analyzedAt":"2026-08-14T22:39:27.425Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}