Skip to content

Commit

Permalink
fix(metric-engine): set ttl also on opening metadata regions (#5051)
Browse files Browse the repository at this point in the history
* fix/metric-metadata-region-options: Remove APPEND_MODE_KEY and refactor TTL option handling in MetricEngineInner

* fix/metric-metadata-region-options: Refactor metadata region options into a shared function

 • Extract metadata region options into region_options_for_metadata_region function
 • Replace inline options map with a call to the new shared function in both create.rs and open.rs files

* fix: exclude typos

* fix/metric-metadata-region-options:
 Refactor metadata region options to accept original options and remove APPEND_MODE_KEY
  • Loading branch information
v0y4g3r authored Nov 26, 2024
1 parent 57f31d1 commit fae141a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
15 changes: 10 additions & 5 deletions src/metric-engine/src/engine/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -456,11 +456,7 @@ impl MetricEngineInner {
// concat region dir
let metadata_region_dir = join_dir(&request.region_dir, METADATA_REGION_SUBDIR);

// remove TTL and APPEND_MODE option
let mut options = request.options.clone();
options.insert(TTL_KEY.to_string(), "10000 years".to_string());
options.remove(APPEND_MODE_KEY);

let options = region_options_for_metadata_region(request.options.clone());
RegionCreateRequest {
engine: MITO_ENGINE_NAME.to_string(),
column_metadatas: vec![
Expand Down Expand Up @@ -539,6 +535,15 @@ impl MetricEngineInner {
}
}

/// Creates the region options for metadata region in metric engine.
pub(crate) fn region_options_for_metadata_region(
mut original: HashMap<String, String>,
) -> HashMap<String, String> {
original.remove(APPEND_MODE_KEY);
original.insert(TTL_KEY.to_string(), "10000 years".to_string());
original
}

#[cfg(test)]
mod test {
use store_api::metric_engine_consts::{METRIC_ENGINE_NAME, PHYSICAL_TABLE_METADATA_KEY};
Expand Down
4 changes: 3 additions & 1 deletion src/metric-engine/src/engine/open.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ use store_api::region_request::{AffectedRows, RegionOpenRequest, RegionRequest};
use store_api::storage::RegionId;

use super::MetricEngineInner;
use crate::engine::create::region_options_for_metadata_region;
use crate::engine::options::set_data_region_options;
use crate::error::{OpenMitoRegionSnafu, Result};
use crate::metrics::{LOGICAL_REGION_COUNT, PHYSICAL_REGION_COUNT};
Expand Down Expand Up @@ -68,9 +69,10 @@ impl MetricEngineInner {
let metadata_region_dir = join_dir(&request.region_dir, METADATA_REGION_SUBDIR);
let data_region_dir = join_dir(&request.region_dir, DATA_REGION_SUBDIR);

let metadata_region_options = region_options_for_metadata_region(request.options.clone());
let open_metadata_region_request = RegionOpenRequest {
region_dir: metadata_region_dir,
options: request.options.clone(),
options: metadata_region_options,
engine: MITO_ENGINE_NAME.to_string(),
skip_wal_replay: request.skip_wal_replay,
};
Expand Down
3 changes: 2 additions & 1 deletion typos.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ extend-exclude = [
"tests-fuzz/src/data/lorem_words",
"*.sql",
"*.result",
"src/pipeline/benches/data.log"
"src/pipeline/benches/data.log",
"cyborg/pnpm-lock.yaml"
]

0 comments on commit fae141a

Please sign in to comment.