tikv/tikv · error
--data-dir must be specified
Error message
--data-dir must be specified
What it means
The tikv-ctl bad-ssts command requires the path to the TiKV data directory to locate the SST/manifest files it inspects. If opt.data_dir is None, an assert! panics with "--data-dir must be specified"; the subsequent expect uses the same message.
Source
Thrown at cmd/tikv-ctl/src/main.rs:149
"ldb" => run_ldb_command(args, &cfg),
"sst_dump" => run_sst_dump_command(args, &cfg),
_ => Opt::command().print_help().unwrap(),
}
}
Cmd::RaftEngineCtl { args } => {
if !validate_storage_data_dir(&mut cfg, opt.data_dir) {
return;
}
let key_manager =
data_key_manager_from_config(&cfg.security.encryption, &cfg.storage.data_dir)
.expect("data_key_manager_from_config should success");
let file_system = Arc::new(ManagedFileSystem::new(key_manager.map(Arc::new), None));
raft_engine_ctl::run_command(args, file_system);
}
Cmd::BadSsts { manifest, pd } => {
let data_dir = opt.data_dir.as_deref();
assert!(data_dir.is_some(), "--data-dir must be specified");
let data_dir = data_dir.expect("--data-dir must be specified");
let pd_client = get_pd_rpc_client(Some(pd), Arc::clone(&mgr));
print_bad_ssts(data_dir, manifest.as_deref(), pd_client, &cfg);
}
Cmd::DumpSnapMeta { file } => {
let path = file.as_ref();
dump_snap_meta_file(path);
}
Cmd::DecryptFile { file, out_file } => {
if !validate_storage_data_dir(&mut cfg, opt.data_dir) {
return;
}
let message =
"This action will expose sensitive data as plaintext on persistent storage";
if !warning_prompt(message) {
return;
}
let infile = &file;
let outfile = &out_file;View on GitHub (pinned to 78aedc1c81)
Solutions
- Pass --data-dir pointing at the TiKV data directory when running bad-ssts
- Fix the invoking script so it includes --data-dir
- Check `tikv-ctl bad-ssts --help` for the exact flag name and expected value
Example fix
// before tikv-ctl bad-ssts --manifest MANIFEST -pd http://pd:2379 // after tikv-ctl bad-ssts --data-dir /tidb/tikv-data --manifest MANIFEST -pd http://pd:2379
Defensive patterns
Strategy: validation
Validate before calling
// shell pre-check
if [ -z "$DATA_DIR" ]; then echo "--data-dir is required for bad-ssts"; exit 1; fi
# in Rust caller
let data_dir = opt.data_dir.as_deref();
if data_dir.is_none() { eprintln!("pass --data-dir for bad-ssts"); std::process::exit(2); } Try / catch
match run_bad_ssts(data_dir, manifest, pd) {
Err(e) => eprintln!("bad-ssts failed: {:?}", e),
Ok(_) => {}
} Prevention
- Always pass --data-dir with bad-ssts
- Wrap tikv-ctl invocations in a script that asserts required flags
- Consult `tikv-ctl bad-ssts --help` for required arguments
When it happens
Trigger: Running `tikv-ctl bad-ssts` without the --data-dir command-line flag.
Common situations: Diagnosing corrupted/missing SSTs after a crash and forgetting --data-dir, scripted invocations where the flag was dropped, or assuming the PD endpoint alone suffices.
Related errors
- must have the region
- unknown log format {}
- invalid auto generated configuration file {}, err {}
- API V3 is not supported by this TiKV build
- only available for local mode
AI-assisted analysis of tikv/tikv@78aedc1c81 (2026-09-03).
Data as JSON: /api/errors/c41f13f2df32854d.
Report an issue: GitHub.