Skip to content

Commit

Permalink
db_bench: fix for issue (#290) (#370)
Browse files Browse the repository at this point in the history
Changed db_bench so that when using multiple databases (num_multi_db > 1) we only destroy databases that were used for the current group (databases specified in dbs_to_use).

Added logic in `OpenAllDbs()` to handle the case where the `-optimistic_transaction_db` option is used.

Co-authored-by: andy-byers <andrew.byers@utdallas.edu>
  • Loading branch information
2 people authored and udi-speedb committed Nov 13, 2023
1 parent 8554a92 commit 6f5ceff
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions tools/db_bench_tool.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2943,7 +2943,6 @@ class Benchmark {
}

void OpenAllDbs(Options options) {
assert(dbs_.empty());
assert(FLAGS_num_multi_db > 0);

// dbs_to_use_ is NOT initialized here since we open the db-s once for all
Expand All @@ -2955,6 +2954,19 @@ class Benchmark {
} else {
auto wal_dir = options.wal_dir;
for (int i = 0; i < FLAGS_num_multi_db; i++) {
#ifndef ROCKSDB_LITE
if (FLAGS_optimistic_transaction_db) {
if (dbs_[i].opt_txn_db) {
continue;
}
} else if (dbs_[i].db) {
continue;
}
#else // ROCKSDB_LITE
if (dbs_[i].db) {
continue;
}
#endif // ROCKSDB_LITE
if (!wal_dir.empty()) {
options.wal_dir = GetPathForMultiple(wal_dir, i);
}
Expand All @@ -2964,17 +2976,17 @@ class Benchmark {
}
}

void DestroyAllDbs() {
// Record the number of db-s as dbs_ is cleared inside DeleteDBs()
auto num_dbs = dbs_.size();

DeleteDBs();
void DestroyUsedDbs() {
for (auto i : db_idxs_to_use) {
dbs_[i].DeleteDBs();
}
dbs_to_use_.clear();

if (num_dbs == 1U) {
if (IsSingleDb()) {
DestroyDB(FLAGS_db, open_options_);
} else if (num_dbs > 1U) {
} else if (IsMultiDb()) {
Options options = open_options_;
for (auto i = 0U; i < num_dbs; ++i) {
for (auto i : db_idxs_to_use) {
if (!open_options_.wal_dir.empty()) {
options.wal_dir = GetPathForMultiple(open_options_.wal_dir, i);
}
Expand Down Expand Up @@ -4023,7 +4035,7 @@ class Benchmark {
"--use_existing_db",
name.c_str());
} else {
DestroyAllDbs();
DestroyUsedDbs();
Open(&open_options_); // use open_options for the last accessed
// There are new DB-s => Re-initialize dbs_to_use_
InitDbsToUse();
Expand Down

0 comments on commit 6f5ceff

Please sign in to comment.