cube-js/cube · error

CacheStore cannot be used on the worker node! persist was us

Error message

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

What it means

CacheStore::persist flushes cache metadata to disk; on worker nodes it is a panic! stub (cache_rocksstore.rs:2088) because persistence belongs to the master store. The panic guards against persistence attempts through a cache-only worker store.

Source

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

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

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

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

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

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

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

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

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

crate::di_service!(ClusterCacheStoreClient, [CacheStore]);

#[cfg(test)]

View on GitHub (pinned to 7d981676b3)

Solutions

  1. Invoke persist only on the master node's store
  2. Gate flush/shutdown logic with a node-role check
  3. Ensure worker processes do not register master-only persistence hooks

Example fix

// before
// shutdown hook on every node
store.persist().await?;
// after
if is_master { store.persist().await?; }
Defensive patterns

Strategy: validation

Validate before calling

if !is_master { return Err(CubeError::internal("persist is master-only")); }
master_client.persist().await?;

Type guard

fn supports_persist(store: &dyn CacheStore) -> bool { node_role == NodeRole::Master }

Try / catch

std::panic::catch_unwind(AssertUnwindSafe(|| master_client.persist())).map_err(|_| CubeError::internal("persist called on worker node"))?;

Prevention

When it happens

Trigger: Calling CacheStore::persist() on a worker-node CacheStore instance (cache_rocksstore.rs:2088), e.g. from a periodic flush task or shutdown hook.

Common situations: Shutdown hooks and flush timers installed on every node regardless of role; code shared between master and worker binaries invoking persist unconditionally.

Related errors


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