{"record":{"id":"8bb71756d7946c5b","repo":"cube-js/cube","slug":"cachestore-cannot-be-used-on-the-worker-node-cach-8bb717","errorCode":null,"errorMessage":"CacheStore cannot be used on the worker node! cache_incr was used.","messagePattern":"CacheStore cannot be used on the worker node! cache_incr was used\\.","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"rust/cubestore/cubestore/src/cachestore/cache_rocksstore.rs","lineNumber":1977,"sourceCode":"\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\n    async fn cache_keys(&self, _prefix: String) -> Result<Vec<IdRow<CacheItem>>, CubeError> {\n        panic!(\"CacheStore cannot be used on the worker node! cache_keys was used.\")\n    }\n\n    async fn cache_incr(&self, _: String) -> Result<IdRow<CacheItem>, CubeError> {\n        panic!(\"CacheStore cannot be used on the worker node! cache_incr was used.\")\n    }\n\n    async fn queue_all(&self, _limit: Option<usize>) -> Result<Vec<QueueAllItem>, CubeError> {\n        panic!(\"CacheStore cannot be used on the worker node! queue_all was used.\")\n    }\n\n    async fn queue_results_all(\n        &self,\n        _limit: Option<usize>,\n    ) -> Result<Vec<IdRow<QueueResult>>, CubeError> {\n        panic!(\"CacheStore cannot be used on the worker node! queue_results_all was used.\")\n    }\n\n    async fn queue_results_multi_delete(&self, _ids: Vec<u64>) -> Result<(), CubeError> {\n        panic!(\"CacheStore cannot be used on the worker node! queue_results_multi_delete was used.\")\n    }\n\n    async fn queue_add(&self, _payload: QueueAddPayload) -> Result<QueueAddResponse, CubeError> {","sourceCodeStart":1959,"sourceCodeEnd":1995,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/rust/cubestore/cubestore/src/cachestore/cache_rocksstore.rs#L1959-L1995","documentation":"ClusterCacheStoreClient (worker-node CacheStore) panics on cache_incr; atomic counter increments on cache items must be performed by the master that owns the underlying store. Workers panic to prevent split-brain counter updates.","triggerScenarios":"Calling cache_incr(key) on a worker node's ClusterCacheStoreClient — e.g. usage counters or rate-limit bookkeeping routed to a worker.","commonSituations":"Counter/semaphore logic accidentally using the worker-local store; distributed rate limiting implemented against the wrong node.","solutions":["Route cache_incr to the master node or the cluster cache client so increments are atomic at the owner.","Redesign the counter path to use the cluster API instead of per-node CacheStore calls.","Verify which node the incrementing component runs on and its configured role."],"exampleFix":"// before\nworker_cache_store.cache_incr(key).await?; // panics on worker\n// after\ncluster.master_cache_store().cache_incr(key).await?;","handlingStrategy":"validation","validationCode":"if node_role() == Role::Worker {\n    return Err(CubeError::internal(\"cache_incr is master-only\"));\n}\ncache_store.cache_incr(key).await?;","typeGuard":"fn is_master_cache(store: &dyn CacheStore) -> bool {\n    std::any::Any::type_id(store) != std::any::TypeId::of::<ClusterCacheStoreClient>()\n}","tryCatchPattern":"if is_worker_cache_stub(cache_store) {\n    return Err(CubeError::internal(\"cache_incr must be executed on the master node\"));\n}\ncache_store.cache_incr(key).await?;","preventionTips":["Perform atomic counter increments on the master store only","Design counters to use the cluster API from any node","Confirm the incrementing component's node role at startup","Never share worker-local CacheStore handles for mutations"],"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"}