{"record":{"id":"ac837f2465cb3242","repo":"apache/superset","slug":"an-error-occurred-while-deleting-the-value","errorCode":null,"errorMessage":"An error occurred while deleting the value.","messagePattern":"An error occurred while deleting the value\\.","errorType":"exception","errorClass":"TemporaryCacheDeleteFailedError","httpStatus":500,"severity":"error","filePath":"superset/commands/explore/form_data/delete.py","lineNumber":65,"sourceCode":"                key\n            )\n            if state:\n                datasource_id: int = state[\"datasource_id\"]\n                chart_id: Optional[int] = state[\"chart_id\"]\n                datasource_type = DatasourceType(state[\"datasource_type\"])\n                check_access(datasource_id, chart_id, datasource_type)\n                if state[\"owner\"] != get_user_id():\n                    raise TemporaryCacheAccessDeniedError()\n                tab_id = self._cmd_params.tab_id\n                contextual_key = cache_key(\n                    session.get(\"_id\"), tab_id, datasource_id, chart_id, datasource_type\n                )\n                cache_manager.explore_form_data_cache.delete(contextual_key)\n                return cache_manager.explore_form_data_cache.delete(key)\n            return False\n        except SQLAlchemyError as ex:\n            logger.exception(\"Error running delete command\")\n            raise TemporaryCacheDeleteFailedError() from ex\n\n    def validate(self) -> None:\n        pass\n","sourceCodeStart":47,"sourceCodeEnd":69,"githubUrl":"https://github.com/apache/superset/blob/f4587218dd19d046c3e4d00063e7d27f8a2ed354/superset/commands/explore/form_data/delete.py#L47-L69","documentation":"TemporaryCacheDeleteFailedError is raised by the explore form_data delete command when any step inside run() — cache get, access checks, or the two cache deletes — surfaces a SQLAlchemyError. The command logs the full exception and re-raises this wrapper, so the root cause lives in the chained exception and the server log.","triggerScenarios":"DELETE /explore JSON call while the metadata database errors (connection lost, pool exhausted, constraint failure on session-related tables) mid-delete of the temporary explore state.","commonSituations":"Metadata DB failover during an explore session cleanup. Pooled connections killed by a LB idle timeout between the get and the delete. Concurrent deletes racing on session rows.","solutions":["Read the chained SQLAlchemyError in logs ('Error running delete command') to identify the failing statement.","Restore/verify metadata DB health, then retry the delete.","Enable pool_pre_ping and sane pool_recycle in SQLALCHEMY_DATABASE_URI options to avoid stale connections.","If the key is already gone server-side, treat a failed delete as benign: the cache entry expires by CACHE_DEFAULT_TIMEOUT anyway."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    DeleteTemporaryExploreStateCommand(...).run()\nexcept TemporaryCacheDeleteFailedError as ex:\n    if is_transient(ex.__cause__):  # SQLAlchemyError underneath\n        retry_once()\n    else:\n        log_and_ignore()  # entries expire via CACHE_DEFAULT_TIMEOUT anyway","preventionTips":["Enable pool_pre_ping to drop dead connections early.","Accept that a failed delete self-heals when the cache TTL lapses.","Check 'Error running delete command' log lines for the true DB cause."],"tags":["explore","cache","database","transient","sqlalchemy"],"backgroundTag":null,"analyzedSha":"f4587218dd19d046c3e4d00063e7d27f8a2ed354","analyzedAt":"2026-08-14T22:39:27.425Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}