Skip to content

Commit

Permalink
config: Fix titan blob-run-mode setting (#15988) (#16014)
Browse files Browse the repository at this point in the history
close #15978, close #15987

Fix titan config blob-run-mode's from<ConfigValue> implementation.

Signed-off-by: tonyxuqqi <tonyxuqi@outlook.com>

Co-authored-by: tonyxuqqi <tonyxuqi@outlook.com>
  • Loading branch information
ti-chi-bot and tonyxuqqi committed Dec 12, 2023
1 parent ec09e54 commit 337602e
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 5 deletions.
11 changes: 7 additions & 4 deletions components/engine_rocks/src/config.rs
Expand Up @@ -340,9 +340,9 @@ pub enum BlobRunMode {
impl From<BlobRunMode> for ConfigValue {
fn from(mode: BlobRunMode) -> ConfigValue {
let str_value = match mode {
BlobRunMode::Normal => "normal",
BlobRunMode::ReadOnly => "read-only",
BlobRunMode::Fallback => "fallback",
BlobRunMode::Normal => "kNormal",
BlobRunMode::ReadOnly => "kReadOnly",
BlobRunMode::Fallback => "kFallback",
};
ConfigValue::String(str_value.into())
}
Expand All @@ -366,8 +366,11 @@ impl FromStr for BlobRunMode {
"normal" => Ok(BlobRunMode::Normal),
"read-only" => Ok(BlobRunMode::ReadOnly),
"fallback" => Ok(BlobRunMode::Fallback),
"kNormal" => Ok(BlobRunMode::Normal),
"kReadOnly" => Ok(BlobRunMode::ReadOnly),
"kFallback" => Ok(BlobRunMode::Fallback),
m => Err(format!(
"expect: normal, read-only or fallback, got: {:?}",
"expect: normal, kNormal, read-only, kReadOnly, kFallback or fallback, got: {:?}",
m
)),
}
Expand Down
23 changes: 22 additions & 1 deletion src/config/mod.rs
Expand Up @@ -5521,7 +5521,28 @@ mod tests {
let diff = config_value_to_string(diff.into_iter().collect());
assert_eq!(diff.len(), 1);
assert_eq!(diff[0].0.as_str(), "blob_run_mode");
assert_eq!(diff[0].1.as_str(), "fallback");
assert_eq!(diff[0].1.as_str(), "kFallback");
}

#[test]
fn test_update_titan_blob_run_mode_config() {
let mut cfg = TikvConfig::default();
cfg.rocksdb.titan.enabled = true;
let (_, cfg_controller, ..) = new_engines::<ApiV1>(cfg);
for run_mode in [
"kFallback",
"kNormal",
"kReadOnly",
"fallback",
"normal",
"read-only",
] {
let change = HashMap::from([(
"rocksdb.defaultcf.titan.blob-run-mode".to_string(),
run_mode.to_string(),
)]);
cfg_controller.update_without_persist(change).unwrap();
}
}

#[test]
Expand Down

0 comments on commit 337602e

Please sign in to comment.