From 635c61fd3b97c02bf0704cf35afc3a2ddb179041 Mon Sep 17 00:00:00 2001 From: Leonidas Galanis Date: Mon, 8 Dec 2014 12:53:24 -0800 Subject: [PATCH] Fix problem with create_if_missing option when wal_dir is used Summary: When wal_dir is used, DestroyDB is not passed the wal_dir option and so we get a Corruption exception. Test Plan: Verified manually that the following command line works now: ./db_bench --db=/mnt/db/rocksdb ... --disable_wal=0 --wal_dir=/data/users/rocksdb/WAL... --benchmarks=filluniquerandom --use_existing_db=0... Reviewers: sdong Reviewed By: sdong Subscribers: dhruba, leveldb Differential Revision: https://reviews.facebook.net/D29859 --- db/db_bench.cc | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/db/db_bench.cc b/db/db_bench.cc index c7fd0365c..34531cc3e 100644 --- a/db/db_bench.cc +++ b/db/db_bench.cc @@ -1367,11 +1367,13 @@ class Benchmark { } void Run() { + Options open_options; // keep options around to properly destroy db later + if (!SanityCheck()) { exit(1); } PrintHeader(); - Open(); + Open(&open_options); const char* benchmarks = FLAGS_benchmarks.c_str(); while (benchmarks != nullptr) { const char* sep = strchr(benchmarks, ','); @@ -1532,15 +1534,15 @@ class Benchmark { delete db_.db; db_.db = nullptr; db_.cfh.clear(); - DestroyDB(FLAGS_db, Options()); + DestroyDB(FLAGS_db, open_options); } for (size_t i = 0; i < multi_dbs_.size(); i++) { delete multi_dbs_[i].db; - DestroyDB(GetDbNameForMultiple(FLAGS_db, i), Options()); + DestroyDB(GetDbNameForMultiple(FLAGS_db, i), open_options); } multi_dbs_.clear(); } - Open(); + Open(&open_options); // use open_options for the last accessed } if (method != nullptr) { @@ -1832,9 +1834,11 @@ class Benchmark { } } - void Open() { + void Open(Options* opts) { + Options& options = *opts; + assert(db_.db == nullptr); - Options options; + options.create_if_missing = !FLAGS_use_existing_db; options.create_missing_column_families = FLAGS_num_column_families > 1; options.db_write_buffer_size = FLAGS_db_write_buffer_size;