cube-js/cube · error

CacheStore cannot be used on the worker node! cache_get was

Error message

CacheStore cannot be used on the worker node! cache_get was used.

What it means

ClusterCacheStoreClient (worker-node CacheStore) panics on cache_get; workers are not a source of cached items. Reads, like writes, must be served by the master node's cache store or the cluster path.

Source

Thrown at rust/cubestore/cubestore/src/cachestore/cache_rocksstore.rs:1969

        _update_if_not_exists: bool,
    ) -> Result<bool, CubeError> {
        panic!("CacheStore cannot be used on the worker node! cache_set was used.")
    }

    async fn cache_clear(&self) -> Result<(), CubeError> {
        panic!("CacheStore cannot be used on the worker node! cache_clear was used.")
    }

    async fn truncate(&self) -> Result<(), CubeError> {
        panic!("CacheStore cannot be used on the worker node! truncate was used.")
    }

    async fn cache_delete(&self, _key: String) -> Result<(), CubeError> {
        panic!("CacheStore cannot be used on the worker node! cache_delete was used.")
    }

    async fn cache_get(&self, _key: String) -> Result<Option<IdRow<CacheItem>>, CubeError> {
        panic!("CacheStore cannot be used on the worker node! cache_get was used.")
    }

    async fn cache_keys(&self, _prefix: String) -> Result<Vec<IdRow<CacheItem>>, CubeError> {
        panic!("CacheStore cannot be used on the worker node! cache_keys was used.")
    }

    async fn cache_incr(&self, _: String) -> Result<IdRow<CacheItem>, CubeError> {
        panic!("CacheStore cannot be used on the worker node! cache_incr was used.")
    }

    async fn queue_all(&self, _limit: Option<usize>) -> Result<Vec<QueueAllItem>, CubeError> {
        panic!("CacheStore cannot be used on the worker node! queue_all was used.")
    }

    async fn queue_results_all(
        &self,
        _limit: Option<usize>,
    ) -> Result<Vec<IdRow<QueueResult>>, CubeError> {

View on GitHub (pinned to 7d981676b3)

Solutions

  1. Perform cache_get against the master node / cluster cache client.
  2. Fix dependency injection so the read path receives the appropriate CacheStore implementation for its role.
  3. Verify the node's cluster role before issuing cache reads.

Example fix

// before
let item = worker_cache_store.cache_get(key).await?; // panics on worker
// after
let item = cluster.master_cache_store().cache_get(key).await?;
Defensive patterns

Strategy: validation

Validate before calling

if node_role() == Role::Worker {
    return Err(CubeError::internal("cache_get is master-only"));
}
let item = cache_store.cache_get(key).await?;

Type guard

fn is_master_cache(store: &dyn CacheStore) -> bool {
    std::any::Any::type_id(store) != std::any::TypeId::of::<ClusterCacheStoreClient>()
}

Try / catch

if is_worker_cache_stub(cache_store) {
    return Err(CubeError::internal("cache reads must target the master node"));
}
let item = cache_store.cache_get(key).await?;

Prevention

When it happens

Trigger: Calling cache_get(key) on a worker node's ClusterCacheStoreClient — e.g. a lookup that assumed it was talking to the node holding the cache.

Common situations: Read-path code accidentally constructed with the worker client; services pointed at a worker endpoint for cache lookups.

Related errors


AI-assisted analysis of cube-js/cube@7d981676b3 (2026-09-02). Data as JSON: /api/errors/901571ad5987b13d. Report an issue: GitHub.