{"record":{"id":"76fc3387a0590a30","repo":"cube-js/cube","slug":"cachestore-cannot-be-used-on-the-worker-node-cach-76fc33","errorCode":null,"errorMessage":"CacheStore cannot be used on the worker node! cache_set was used.","messagePattern":"CacheStore cannot be used on the worker node! cache_set was used\\.","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"rust/cubestore/cubestore/src/cachestore/cache_rocksstore.rs","lineNumber":1953,"sourceCode":"}\n\ncrate::di_service!(RocksCacheStore, [CacheStore]);\ncrate::di_service!(CacheStoreRpcClient, [CacheStore]);\n\npub struct ClusterCacheStoreClient {}\n\n#[async_trait]\nimpl CacheStore for ClusterCacheStoreClient {\n    async fn cache_all(&self, _limit: Option<usize>) -> Result<Vec<IdRow<CacheItem>>, CubeError> {\n        panic!(\"CacheStore cannot be used on the worker node! cache_all was used.\")\n    }\n\n    async fn cache_set(\n        &self,\n        _item: CacheItem,\n        _update_if_not_exists: bool,\n    ) -> Result<bool, CubeError> {\n        panic!(\"CacheStore cannot be used on the worker node! cache_set was used.\")\n    }\n\n    async fn cache_clear(&self) -> Result<(), CubeError> {\n        panic!(\"CacheStore cannot be used on the worker node! cache_clear was used.\")\n    }\n\n    async fn truncate(&self) -> Result<(), CubeError> {\n        panic!(\"CacheStore cannot be used on the worker node! truncate was used.\")\n    }\n\n    async fn cache_delete(&self, _key: String) -> Result<(), CubeError> {\n        panic!(\"CacheStore cannot be used on the worker node! cache_delete was used.\")\n    }\n\n    async fn cache_get(&self, _key: String) -> Result<Option<IdRow<CacheItem>>, CubeError> {\n        panic!(\"CacheStore cannot be used on the worker node! cache_get was used.\")\n    }\n","sourceCodeStart":1935,"sourceCodeEnd":1971,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/rust/cubestore/cubestore/src/cachestore/cache_rocksstore.rs#L1935-L1971","documentation":"ClusterCacheStoreClient (worker-node CacheStore) panics on cache_set because workers must not write to the local cache store directly. Cache item creation/updates must be performed on the master node or via the cluster-distributed path. The panic names the offending method to make the misroute obvious.","triggerScenarios":"Calling cache_set(item, update_if_not_exists) on a worker node's ClusterCacheStoreClient — e.g. result-cache write logic executed on a worker that assumed local cache ownership.","commonSituations":"Worker node receiving cache-write traffic intended for the master; misconfigured load balancing; custom tooling invoking cache APIs against a worker endpoint.","solutions":["Send cache_set operations to the master node or use the cluster-aware cache client.","Review node role configuration; make the writer a master or enable the proper cache delegation path.","In code, resolve the CacheStore via the cluster/metastore so writes are delegated, not aimed at the worker stub."],"exampleFix":"// before\nworker_cache_store.cache_set(item, true).await?; // panics on worker\n// after\ncluster_cache_client.cache_set(item, true).await?; // delegated via master","handlingStrategy":"validation","validationCode":"if node_role() == Role::Worker {\n    return Err(CubeError::internal(\"cache_set is master-only\"));\n}\ncache_store.cache_set(item, true).await?;","typeGuard":"fn can_mutate_cache(store: &dyn CacheStore) -> bool {\n    std::any::Any::type_id(store) != std::any::TypeId::of::<ClusterCacheStoreClient>()\n}","tryCatchPattern":"if std::any::TypeId::of::<ClusterCacheStoreClient>() == store_type_id() {\n    return Err(CubeError::internal(\"cache_set must be routed via the master node\"));\n}\ncache_store.cache_set(item, update_if_not_exists).await?;","preventionTips":["Route cache writes through the master or cluster delegation API","Inject the correct CacheStore implementation based on node role","Never broadcast cache writes to every cluster node","Add role checks before invoking CacheStore mutation methods"],"tags":["rust","cubestore","cluster","cache","worker-node"],"backgroundTag":"cache-store-worker-node-unsupported","analyzedSha":"7d981676b36392fec34088b9afab6bdcad40207c","analyzedAt":"2026-09-02T03:45:10.400Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}