{"record":{"id":"9a511a571964b93f","repo":"databendlabs/databend","slug":"raft-dir-of-meta-service-must-be-an-absolute-path","errorCode":null,"errorMessage":"raft_dir of meta service must be an absolute path, but got: {:?}","messagePattern":"raft_dir of meta service must be an absolute path, but got: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/bendsave/src/storage.rs","lineNumber":85,"sourceCode":"pub fn load_query_storage(cfg: &InnerConfig) -> Result<Operator> {\n    let op = init_operator(&cfg.storage.params)?;\n    debug!(\"databend storage loaded: {:?}\", op.info());\n    Ok(op)\n}\n\n/// Load the configuration file of databend meta.\n///\n/// The given input is the path to databend meta's configuration file.\npub fn load_meta_config(path: &str) -> Result<MetaServiceConfig> {\n    let content = std::fs::read_to_string(path)?;\n    let outer_config: databend_meta_cli_config::Config = toml::from_str(&content)?;\n    let meta_config: MetaConfig = outer_config\n        .try_into()\n        .map_err(|msg: String| anyhow!(\"{msg}\"))?;\n    let service_config = meta_config.service;\n\n    if !service_config.raft_config.raft_dir.starts_with(\"/\") {\n        return Err(anyhow!(\n            \"raft_dir of meta service must be an absolute path, but got: {:?}\",\n            service_config.raft_config.raft_dir\n        ));\n    }\n\n    debug!(\"databend meta storage loaded: {:?}\", service_config);\n    Ok(service_config)\n}\n\n/// Init databend query instance so that we can read meta and check license\n/// for it.\n///\n/// FIXME: I really don't like this pattern, but it's how databend work.\npub fn init_query(cfg: &InnerConfig) -> Result<()> {\n    GlobalInstance::init_production();\n\n    GlobalConfig::init(cfg, &BUILD_INFO)?;\n    GlobalIORuntime::init(cfg.storage.num_cpus as usize)?;","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/databendlabs/databend/blob/288d84d76e20a2f8f7173bda9691eb6ece301aa9/src/bendsave/src/storage.rs#L67-L103","documentation":"`load_meta_config` validates that the meta service's `raft_config.raft_dir` is an absolute path (starts with `/`) and returns this error when it is not. The restore path needs to locate the raft data directory directly, so a relative path would resolve against an unpredictable working directory.","triggerScenarios":"Calling `load_meta_config` (directly or via `restore`) with a meta config whose `[raft_config] raft_dir` value is relative, e.g. `\"./meta\"` or `\"meta_data\"`.","commonSituations":"Hand-written or copied meta configs using relative paths; configs generated for environments where the meta process was launched from a fixed working directory so a relative path happened to work there.","solutions":["Edit the meta config file and set `raft_config.raft_dir` to an absolute path (e.g. `/var/lib/databend/meta`).","Verify the directory actually exists and contains the raft data before restoring.","If the config is generated by a script, make the script emit absolute paths.","Re-run restore after fixing the path."],"exampleFix":"// before (meta config toml)\n[raft_config]\nraft_dir = \"./meta_data\"\n\n// after\n[raft_config]\nraft_dir = \"/var/lib/databend/meta_data\"","handlingStrategy":"validation","validationCode":"let dir = cfg[\"raft_config\"][\"raft_dir\"].as_str().unwrap();\nif !dir.starts_with('/') {\n    return Err(format!(\"raft_dir must be absolute, got: {dir}\"));\n}\nif !std::path::Path::new(dir).is_dir() {\n    return Err(format!(\"raft_dir does not exist: {dir}\"));\n}","typeGuard":"fn is_absolute_existing_dir(p: &str) -> bool {\n    p.starts_with('/') && std::path::Path::new(p).is_dir()\n}","tryCatchPattern":"match bendsave::load_meta_config(path) {\n    Ok(cfg) => cfg,\n    Err(e) if e.to_string().contains(\"raft_dir\") => {\n        eprintln!(\"fix raft_dir in {path}: {e}\");\n        std::process::exit(2);\n    }\n    Err(e) => return Err(e.into()),\n}","preventionTips":["Always use absolute paths for raft_dir in meta configs","Have config generators resolve paths with realpath/canonicalization","Check the directory exists and is readable before running restore","Document the absolute-path requirement in config templates"],"tags":["config","path","raft","bendsave","validation"],"backgroundTag":"invalid-config-value","analyzedSha":"288d84d76e20a2f8f7173bda9691eb6ece301aa9","analyzedAt":"2026-09-11T11:29:36.208Z","contentChangedAt":"2026-09-11T11:29:36.208Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}