cube-js/cube · error

CacheStore cannot be used on the worker node! cache_clear wa

Error message

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

What it means

ClusterCacheStoreClient (worker-node CacheStore) panics on cache_clear because clearing the cache is a master-owned operation; workers have no local cache authority. The panic prevents workers from silently diverging from the master's cache state.

Source

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

pub struct ClusterCacheStoreClient {}

#[async_trait]
impl CacheStore for ClusterCacheStoreClient {
    async fn cache_all(&self, _limit: Option<usize>) -> Result<Vec<IdRow<CacheItem>>, CubeError> {
        panic!("CacheStore cannot be used on the worker node! cache_all was used.")
    }

    async fn cache_set(
        &self,
        _item: CacheItem,
        _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.")
    }

View on GitHub (pinned to 7d981676b3)

Solutions

  1. Issue cache_clear only to the master/head node so it propagates cluster-wide.
  2. Update cluster administration tooling to filter worker nodes out of cache-management calls.
  3. Verify node roles; if this node should own the cache, start it with master configuration.

Example fix

// before
for node in all_nodes { node.cache_store.cache_clear().await?; } // panics on workers
// after
master_node.cache_store.cache_clear().await?; // master clears for the cluster
Defensive patterns

Strategy: validation

Validate before calling

if node_role() == Role::Worker {
    return Err(CubeError::internal("cache_clear is master-only"));
}
cache_store.cache_clear().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("send cache_clear to the master node"));
}
cache_store.cache_clear().await?;

Prevention

When it happens

Trigger: Calling cache_clear() on a worker node's ClusterCacheStoreClient, e.g. an admin/eviction routine issuing a cache flush to every node in the cluster.

Common situations: Cluster-wide 'flush cache' tooling that broadcasts to all nodes including workers; ops scripts targeting the wrong node's API.

Related errors


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