From 6811fb06581e3ca0bd856a0473ee03e18e7178f2 Mon Sep 17 00:00:00 2001 From: Zhichao Cao Date: Fri, 20 Jul 2018 15:44:00 -0700 Subject: [PATCH] Fixed the db_bench MergeRandom only access CF_default (#4155) Summary: When running the tracing and analyzing, I found that MergeRandom benchmark in db_bench only access the default column family even the -num_column_families is specified > 1. changes: Using the db_with_cfh as DB to randomly select the column family to execute the Merge operation if -num_column_families is specified > 1. Tested with make asan_check and verified in tracing Pull Request resolved: https://github.com/facebook/rocksdb/pull/4155 Differential Revision: D8907888 Pulled By: zhichao-cao fbshipit-source-id: 2b4bc8fe0e99c8f262f5be6b986c7025d62cf850 --- tools/db_bench_tool.cc | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/tools/db_bench_tool.cc b/tools/db_bench_tool.cc index 7f8676e8d..9dd946c29 100644 --- a/tools/db_bench_tool.cc +++ b/tools/db_bench_tool.cc @@ -5061,17 +5061,27 @@ void VerifyDBFromDB(std::string& truth_db_name) { // The number of iterations is the larger of read_ or write_ Duration duration(FLAGS_duration, readwrites_); while (!duration.Done(1)) { - DB* db = SelectDB(thread); - GenerateKeyFromInt(thread->rand.Next() % merge_keys_, merge_keys_, &key); + DBWithColumnFamilies* db_with_cfh = SelectDBWithCfh(thread); + int64_t key_rand = thread->rand.Next() % merge_keys_; + GenerateKeyFromInt(key_rand, merge_keys_, &key); - Status s = db->Merge(write_options_, key, gen.Generate(value_size_)); + Status s; + if (FLAGS_num_column_families > 1) { + s = db_with_cfh->db->Merge(write_options_, + db_with_cfh->GetCfh(key_rand), key, + gen.Generate(value_size_)); + } else { + s = db_with_cfh->db->Merge(write_options_, + db_with_cfh->db->DefaultColumnFamily(), key, + gen.Generate(value_size_)); + } if (!s.ok()) { fprintf(stderr, "merge error: %s\n", s.ToString().c_str()); exit(1); } bytes += key.size() + value_size_; - thread->stats.FinishedOps(nullptr, db, 1, kMerge); + thread->stats.FinishedOps(nullptr, db_with_cfh->db, 1, kMerge); } // Print some statistics