Skip to content

Commit

Permalink
Avoid div-by-zero error in db_stress (#9086)
Browse files Browse the repository at this point in the history
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: #9086

Test Plan: TBD

Reviewed By: ajkr

Differential Revision: D31986799

Pulled By: riversand963

fbshipit-source-id: 48f7dfb2b2b47cfc1315cb71ca80eb230d947f17
  • Loading branch information
riversand963 authored and facebook-github-bot committed Nov 1, 2021
1 parent 8e59a1d commit d263505
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions db_stress_tool/db_stress_test_base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1812,6 +1812,10 @@ void StressTest::TestCompactFiles(ThreadState* thread,
ROCKSDB_NAMESPACE::ColumnFamilyMetaData 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
const int kMaxRetry = 3;
for (int attempt = 0; attempt < kMaxRetry; ++attempt) {
Expand Down

0 comments on commit d263505

Please sign in to comment.