influxdata/influxdb · error · Error

requested last cache does not exist

Error message

requested last cache does not exist

What it means

This is the `CacheDoesNotExist` variant of the last_cache `Error` enum in influxdb3_cache. It is returned when an operation (e.g. reading, deleting, or altering a last-value cache) references a last cache by name/table but no such cache is registered in the catalog. The library throws it instead of silently returning empty results so callers can distinguish 'cache missing' from 'cache empty'.

Solutions

  1. List existing last caches (e.g. via catalog/`information_schema` or SHOW) and confirm the exact table and cache name you reference.
  2. Create the cache first with `CREATE LAST CACHE <table> ...` before reading or altering it.
  3. Fix the typo or wrong table name in the statement or API call.
  4. If caches should survive restarts, enable/verify last-cache persistence configuration instead of relying on in-memory state.

Example fix

// before
client.get_last_cache("cpu", "cache_typo")?; // Error::CacheDoesNotExist
// after
let caches = client.list_last_caches("cpu")?;
if caches.iter().any(|c| c.name == "cache_typo") {
    client.get_last_cache("cpu", "cache_typo")?;
} else {
    client.create_last_cache("cpu", "cache_typo", /* key/value columns */)?;
}
Defensive patterns

Strategy: validation

Validate before calling

// Rust-ish pseudo-check before reading/altering a cache
let exists = catalog.list_last_caches(table)?.iter().any(|c| c.name == cache_name);
if !exists { return Err(anyhow!("last cache '{}' on table '{}' does not exist", cache_name, table)); }

Type guard

fn cache_exists(caches: &[LastCacheInfo], table: &str, name: &str) -> bool {
    caches.iter().any(|c| c.table == table && c.name == name)
}

Try / catch

match result {
    Err(e) if e.to_string().contains("requested last cache does not exist") => create_or_recreate_cache(),
    other => other?,
}

Prevention

When it happens

Trigger: Calling a last-cache API (get/read/alter/delete cache) with a table+cache name combination that was never created via `CREATE LAST CACHE`, or referencing a cache that was already dropped or was lost because the node was restarted without cache persistence.

Common situations: Typo in the cache or table name in SQL like `ALTER LAST CACHE ...`; querying a cache after a `DROP LAST CACHE` ran in another session; referencing caches from a different node's spec in multi-node setups; upgrade/restart wiped in-memory caches.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


AI-assisted analysis of influxdata/influxdb@06200ef96b (2026-09-19). Data as JSON: /api/errors/40aa8cb1c8b0fa0b. Report an issue: GitHub.

Appendix: source

Thrown at influxdb3_cache/src/last_cache/mod.rs:34

    #[error("invalid cache size")]
    InvalidCacheSize,
    #[error(
        "last cache already exists for database and table, but it was configured differently: {reason}"
    )]
    CacheAlreadyExists { reason: String },
    #[error("specified column (name: {column_name}) does not exist in the table definition")]
    ColumnDoesNotExistByName { column_name: String },
    #[error("specified column (id: {column_id}) does not exist in the table definition")]
    ColumnDoesNotExistById { column_id: ColumnId },
    #[error("specified key column (id: {column_id}) does not exist in the table schema")]
    KeyColumnDoesNotExist { column_id: ColumnId },
    #[error("specified key column (name: {column_name}) does not exist in the table schema")]
    KeyColumnDoesNotExistByName { column_name: String },
    #[error("key column must be string, int, uint, or bool types, got: {column_type}")]
    InvalidKeyColumn { column_type: InfluxColumnType },
    #[error("specified value column ({column_id}) does not exist in the table schema")]
    ValueColumnDoesNotExist { column_id: ColumnId },
    #[error("requested last cache does not exist")]
    CacheDoesNotExist,
}

impl Error {
    fn cache_already_exists(reason: impl Into<String>) -> Self {
        Self::CacheAlreadyExists {
            reason: reason.into(),
        }
    }
}

#[cfg(test)]
mod tests;

View on GitHub (pinned to 06200ef96b)