Fix readrandom return NotFound after fillrandom in db_bench (#6665)

Summary:
This commit is fixing a bug that readrandom test returns many NotFound in db_bench from Version 6.2.
Pull Request resolved: https://github.com/facebook/rocksdb/issues/6664
Pull Request resolved: https://github.com/facebook/rocksdb/pull/6665

Reviewed By: cheng-chang

Differential Revision: D20911298

Pulled By: ajkr

fbshipit-source-id: c2658d4dbb35798ccbf67dff6e64923fb731ef81
main
CaixinGong 5 years ago committed by Facebook GitHub Bot
parent d648a0e17f
commit a91613dd06
  1. 4
      tools/db_bench_tool.cc

@ -5040,7 +5040,7 @@ class Benchmark {
int64_t found = 0; int64_t found = 0;
int64_t bytes = 0; int64_t bytes = 0;
int num_keys = 0; int num_keys = 0;
int64_t key_rand = GetRandomKey(&thread->rand); int64_t key_rand = 0;
ReadOptions options(FLAGS_verify_checksum, true); ReadOptions options(FLAGS_verify_checksum, true);
std::unique_ptr<const char[]> key_guard; std::unique_ptr<const char[]> key_guard;
Slice key = AllocateKey(&key_guard); Slice key = AllocateKey(&key_guard);
@ -5052,7 +5052,6 @@ class Benchmark {
// We use same key_rand as seed for key and column family so that we can // We use same key_rand as seed for key and column family so that we can
// deterministically find the cfh corresponding to a particular key, as it // deterministically find the cfh corresponding to a particular key, as it
// is done in DoWrite method. // is done in DoWrite method.
GenerateKeyFromInt(key_rand, FLAGS_num, &key);
if (entries_per_batch_ > 1 && FLAGS_multiread_stride) { if (entries_per_batch_ > 1 && FLAGS_multiread_stride) {
if (++num_keys == entries_per_batch_) { if (++num_keys == entries_per_batch_) {
num_keys = 0; num_keys = 0;
@ -5067,6 +5066,7 @@ class Benchmark {
} else { } else {
key_rand = GetRandomKey(&thread->rand); key_rand = GetRandomKey(&thread->rand);
} }
GenerateKeyFromInt(key_rand, FLAGS_num, &key);
read++; read++;
Status s; Status s;
if (FLAGS_num_column_families > 1) { if (FLAGS_num_column_families > 1) {

Loading…
Cancel
Save