Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MRG: propagate error from RocksDB::open on bad directory #3306

Merged
merged 2 commits into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/core/src/index/revindex/disk_revindex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ impl RevIndex {

info!("Compact SSTs");
index.compact();
info!("Processed {} reference sigs", processed_sigs.into_inner());
info!("Done! Processed {} reference sigs", processed_sigs.into_inner());

Ok(module::RevIndex::Plain(index))
}
Expand Down
12 changes: 11 additions & 1 deletion src/core/src/index/revindex/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ impl RevIndex {

pub fn open<P: AsRef<Path>>(index: P, read_only: bool, spec: Option<&str>) -> Result<Self> {
let opts = db_options();
let cfs = DB::list_cf(&opts, index.as_ref()).unwrap();
let cfs = DB::list_cf(&opts, index.as_ref())?;

if cfs.into_iter().any(|c| c == COLORS) {
// TODO: ColorRevIndex can't be read-only for now,
Expand Down Expand Up @@ -1020,4 +1020,14 @@ mod test {

Ok(())
}

#[test]
fn rocksdb_storage_fail_bad_directory() -> Result<()> {
let testdir = TempDir::new()?;

match RevIndex::open(testdir, true, None) {
Err(_) => Ok(()),
Ok(_) => panic!("test should not reach here"),
}
}
}
Loading