{"record":{"id":"943e1ee0b4d5a481","repo":"influxdata/influxdb","slug":"invalid-cache-size","errorCode":null,"errorMessage":"invalid cache size","messagePattern":"invalid cache size","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"influxdb3_cache/src/last_cache/mod.rs","lineNumber":16,"sourceCode":"//! The Last-N-Value cache holds the most N recent values for a column or set of columns on a table\n\nuse influxdb3_id::ColumnId;\n\nmod cache;\npub use cache::CreateLastCacheArgs;\nmod metrics;\nmod provider;\npub use provider::{LastCacheProvider, background_catalog_update};\nmod table_function;\nuse schema::InfluxColumnType;\npub use table_function::{LAST_CACHE_UDTF_NAME, LastCacheFunction};\n\n#[derive(Debug, thiserror::Error)]\npub enum Error {\n    #[error(\"invalid cache size\")]\n    InvalidCacheSize,\n    #[error(\n        \"last cache already exists for database and table, but it was configured differently: {reason}\"\n    )]\n    CacheAlreadyExists { reason: String },\n    #[error(\"specified column (name: {column_name}) does not exist in the table definition\")]\n    ColumnDoesNotExistByName { column_name: String },\n    #[error(\"specified column (id: {column_id}) does not exist in the table definition\")]\n    ColumnDoesNotExistById { column_id: ColumnId },\n    #[error(\"specified key column (id: {column_id}) does not exist in the table schema\")]\n    KeyColumnDoesNotExist { column_id: ColumnId },\n    #[error(\"specified key column (name: {column_name}) does not exist in the table schema\")]\n    KeyColumnDoesNotExistByName { column_name: String },\n    #[error(\"key column must be string, int, uint, or bool types, got: {column_type}\")]\n    InvalidKeyColumn { column_type: InfluxColumnType },\n    #[error(\"specified value column ({column_id}) does not exist in the table schema\")]\n    ValueColumnDoesNotExist { column_id: ColumnId },\n    #[error(\"requested last cache does not exist\")]","sourceCodeStart":1,"sourceCodeEnd":34,"githubUrl":"https://github.com/influxdata/influxdb/blob/06200ef96ba82c5f6727e5038a83af8e722c6875/influxdb3_cache/src/last_cache/mod.rs#L1-L34","documentation":"Error::InvalidCacheSize is thrown by the last-n-nodes cache when a configured cache size is invalid. The last cache is bounded by a maximum number of entries, and creating or resizing it with a non-positive or otherwise unacceptable size fails with this error. It is a configuration validation failure at cache creation/update time.","triggerScenarios":"Calling last cache creation APIs (e.g. create/upsert with a LastCacheSize argument) with a size of 0 or a value out of the accepted range; passing an invalid max card/size field in cache configuration via the write path or SQL CREATE CACHE.","commonSituations":"Copy-pasted config with size 0; computing the size dynamically and passing an uninitialized/empty value; unit mismatches (entries vs bytes); version changes where previously accepted sizes are now rejected.","solutions":["Set the cache size to a positive integer within the allowed range","Audit the cache configuration source (SQL statement, config file, or API call) for a zero or negative size","Use the library's size constructor (which validates) instead of raw integers to catch invalid sizes early","Check the influxdb3_cache version's accepted size limits and adjust the configuration"],"exampleFix":"// before\nlet size = LastCacheSize::new(0); // panics/errors later: invalid cache size\n// after\nlet n = 0usize;\nif n == 0 { return Err(\"last cache size must be > 0\".into()); }\nlet size = LastCacheSize::new(n);","handlingStrategy":"validation","validationCode":"// validate before calling the cache API\nfn valid_size(n: usize) -> Result<usize, String> {\n    if n == 0 { Err(\"last cache size must be a positive integer\".into()) }\n    else { Ok(n) }\n}","typeGuard":null,"tryCatchPattern":"match provider.create_last_cache(db, table, cfg) {\n    Err(Error::InvalidCacheSize) => {\n        // fall back to a sane default\n        provider.create_last_cache(db, table, cfg.with_size(default_size))?\n    }\n    r => r?,\n}","preventionTips":["Never hardcode 0 or negative-derived values for cache size","Load cache sizes from validated config with explicit >0 assertions","Use the library's typed size constructors that reject invalid values at construction"],"tags":["cache","configuration","validation","rust"],"backgroundTag":"invalid-config-value","analyzedSha":"06200ef96ba82c5f6727e5038a83af8e722c6875","analyzedAt":"2026-09-19T12:55:30.003Z","contentChangedAt":"2026-09-19T12:55:30.003Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}