diff --git a/influxdb3/src/commands/create.rs b/influxdb3/src/commands/create.rs index 2e8e2985b3c..aaf13eea9dd 100644 --- a/influxdb3/src/commands/create.rs +++ b/influxdb3/src/commands/create.rs @@ -145,7 +145,7 @@ pub struct LastCacheConfig { #[clap(short = 't', long = "table")] table: String, - /// Which columns in the table to use as keys in the cache. This is a comma separated list. + /// Which columns in the table to use as keys in the cache. This is a comma separated list /// /// Example: --key-columns "foo,bar,baz" #[clap(long = "key-columns", value_delimiter = ',')] @@ -158,15 +158,16 @@ pub struct LastCacheConfig { value_columns: Option>, /// The number of entries per unique key column combination the cache will store - #[clap(long = "count")] + /// + /// Higher values can increase memory usage significantly + #[clap(long = "count", default_value = "1")] count: Option, - /// The time-to-live (TTL) for entries in a cache. This uses a humantime form for example: --ttl "10s", - /// --ttl "1min 30sec", --ttl "3 hours" + /// The time-to-live (TTL) for entries in a cache. This uses a humantime form: "10s", "1min 30sec", "3 hours" /// /// See the parse_duration docs for more details about acceptable forms: /// - #[clap(long = "ttl")] + #[clap(long = "ttl", default_value = "4 hours")] ttl: Option, /// Give a name for the cache. @@ -475,7 +476,7 @@ mod tests { "--ttl", "1 hour", "--count", - "5", + "15", "bar", ]); let super::SubCommand::LastCache(super::LastCacheConfig { @@ -496,7 +497,7 @@ mod tests { assert!(cache_name.is_some_and(|n| n == "bar")); assert!(key_columns.is_some_and(|keys| keys == ["tag1", "tag2", "tag3"])); assert!(value_columns.is_some_and(|vals| vals == ["field1", "field2", "field3"])); - assert!(count.is_some_and(|c| c == 5)); + assert!(count.is_some_and(|c| c == 15)); assert!(ttl.is_some_and(|t| t.as_secs() == 3600)); } diff --git a/influxdb3/tests/server/configure.rs b/influxdb3/tests/server/configure.rs index 0e381920c32..52b9e49d7ed 100644 --- a/influxdb3/tests/server/configure.rs +++ b/influxdb3/tests/server/configure.rs @@ -528,8 +528,8 @@ async fn api_v3_configure_last_cache_create() { description: "Use an invalid cache size is a bad request", db: Some(db_name), table: Some(tbl_name), - cache_name: Some("too_big"), - count: Some(11), + cache_name: Some("too_small"), + count: Some(0), expected: StatusCode::BAD_REQUEST, ..Default::default() }, diff --git a/influxdb3_cache/src/last_cache/mod.rs b/influxdb3_cache/src/last_cache/mod.rs index 8c6851e05b8..ff45c213dd0 100644 --- a/influxdb3_cache/src/last_cache/mod.rs +++ b/influxdb3_cache/src/last_cache/mod.rs @@ -1236,7 +1236,7 @@ mod tests { Some("test_cache_3"), Option::<&[&str]>::Some(&[]), Some(&["f2", "time"]), - LastCacheSize::new(10).unwrap(), + LastCacheSize::new(100).unwrap(), LastCacheTtl::from_secs(500), ) .await diff --git a/influxdb3_cache/src/last_cache/snapshots/influxdb3_cache__last_cache__tests__catalog_initialization.snap b/influxdb3_cache/src/last_cache/snapshots/influxdb3_cache__last_cache__tests__catalog_initialization.snap index 2656dd7abab..aff77349522 100644 --- a/influxdb3_cache/src/last_cache/snapshots/influxdb3_cache__last_cache__tests__catalog_initialization.snap +++ b/influxdb3_cache/src/last_cache/snapshots/influxdb3_cache__last_cache__tests__catalog_initialization.snap @@ -249,7 +249,7 @@ expression: catalog.snapshot() 2, 3 ], - "n": 10, + "n": 100, "ttl": 500 } ] diff --git a/influxdb3_catalog/src/error.rs b/influxdb3_catalog/src/error.rs index 3698d596543..004f0b9e215 100644 --- a/influxdb3_catalog/src/error.rs +++ b/influxdb3_catalog/src/error.rs @@ -152,7 +152,7 @@ pub enum CatalogError { #[error("failed to parse trigger from {}", trigger_spec)] ProcessingEngineTriggerSpecParseError { trigger_spec: String }, - #[error("last cache size must be from 1 to 10")] + #[error("last cache size must be greater than 0")] InvalidLastCacheSize, #[error("failed to parse trigger from {trigger_spec}{}", .context.as_ref().map(|context| format!(": {context}")).unwrap_or_default())] diff --git a/influxdb3_catalog/src/log/versions/v2.rs b/influxdb3_catalog/src/log/versions/v2.rs index 4cd26cbb24d..fd1a0869668 100644 --- a/influxdb3_catalog/src/log/versions/v2.rs +++ b/influxdb3_catalog/src/log/versions/v2.rs @@ -380,18 +380,15 @@ pub enum LastCacheValueColumnsDef { AllNonKeyColumns, } -/// The maximum allowed size for a last cache -pub const LAST_CACHE_MAX_SIZE: usize = 10; - /// The size of the last cache /// -/// Must be between 1 and [`LAST_CACHE_MAX_SIZE`] +/// Must be greater than 0 #[derive(Debug, Serialize, Eq, PartialEq, Clone, Copy)] pub struct LastCacheSize(pub(crate) usize); impl LastCacheSize { pub fn new(size: usize) -> Result { - if size == 0 || size > LAST_CACHE_MAX_SIZE { + if size == 0 { Err(CatalogError::InvalidLastCacheSize) } else { Ok(Self(size))