Skip to content

Commit

Permalink
Propagate empty CF export as snapshot error
Browse files Browse the repository at this point in the history
  • Loading branch information
pcholakov committed Feb 13, 2025
1 parent 9194379 commit 46a53c4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions crates/rocksdb/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ pub enum RocksError {
#[error("invalid key range for partition")]
#[code(unknown)]
SnapshotKeyRangeMismatch,
#[error("export column family returned an empty set of SST files")]
#[code(unknown)]
SnapshotEmpty,
#[error(transparent)]
#[code(unknown)]
Other(#[from] rocksdb::Error),
Expand Down
9 changes: 9 additions & 0 deletions crates/rocksdb/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,15 @@ impl RocksDb {
.export_column_family(&data_cf_handle, export_dir.as_path())
.map_err(RocksError::Other)?;

if metadata.get_files().is_empty() {
warn!(
"Refusing to create an empty snapshot! RocksDB column family export \
returned an empty set of files. The export is retained at: {}",
export_dir.display()
);
return Err(RocksError::SnapshotEmpty);
}

Ok(metadata)
})
.build()
Expand Down

0 comments on commit 46a53c4

Please sign in to comment.