Avoid div-by-zero error in db_stress (#9086)

Summary:
If a column family has 0 levels, then existing `TestCompactFiles(...)` may hit
divide-by-zero. To fix, return early if the cf is empty.

Pull Request resolved: https://github.com/facebook/rocksdb/pull/9086

Test Plan: TBD

Reviewed By: ajkr

Differential Revision: D31986799

Pulled By: riversand963

fbshipit-source-id: 48f7dfb2b2b47cfc1315cb71ca80eb230d947f17
main
Yanqin Jin 3 years ago committed by Facebook GitHub Bot
parent 8e59a1dc9a
commit d263505417
  1. 4
      db_stress_tool/db_stress_test_base.cc

@ -1812,6 +1812,10 @@ void StressTest::TestCompactFiles(ThreadState* thread,
ROCKSDB_NAMESPACE::ColumnFamilyMetaData cf_meta_data; ROCKSDB_NAMESPACE::ColumnFamilyMetaData cf_meta_data;
db_->GetColumnFamilyMetaData(column_family, &cf_meta_data); db_->GetColumnFamilyMetaData(column_family, &cf_meta_data);
if (cf_meta_data.levels.empty()) {
return;
}
// Randomly compact up to three consecutive files from a level // Randomly compact up to three consecutive files from a level
const int kMaxRetry = 3; const int kMaxRetry = 3;
for (int attempt = 0; attempt < kMaxRetry; ++attempt) { for (int attempt = 0; attempt < kMaxRetry; ++attempt) {

Loading…
Cancel
Save