mirror of
https://github.com/facebook/rocksdb.git
synced 2024-11-26 07:30:54 +00:00
Abort db_bench if Get() returns error
Summary: I saw this when running readrandom benchmark with corrupted database -- benchmark worked! If a Get() returns corruption we should probably abort. Test Plan: compiles Reviewers: yhchiang, rven, sdong Reviewed By: sdong Subscribers: dhruba, leveldb Differential Revision: https://reviews.facebook.net/D31701
This commit is contained in:
parent
206237d121
commit
423dee8418
|
@ -2392,8 +2392,13 @@ class Benchmark {
|
|||
int64_t key_rand = thread->rand.Next() & (pot - 1);
|
||||
GenerateKeyFromInt(key_rand, FLAGS_num, &key);
|
||||
++read;
|
||||
if (db->Get(options, key, &value).ok()) {
|
||||
auto status = db->Get(options, key, &value);
|
||||
if (status.ok()) {
|
||||
++found;
|
||||
} else if (!status.IsNotFound()) {
|
||||
fprintf(stderr,
|
||||
"Get returned an error: %s\n" status.ToString().c_str());
|
||||
abort();
|
||||
}
|
||||
if (key_rand >= FLAGS_num) {
|
||||
++nonexist;
|
||||
|
@ -2440,6 +2445,9 @@ class Benchmark {
|
|||
}
|
||||
if (s.ok()) {
|
||||
found++;
|
||||
} else if (!s.IsNotFound()) {
|
||||
fprintf(stderr, "Get returned an error: %s\n" s.ToString().c_str());
|
||||
abort();
|
||||
}
|
||||
thread->stats.FinishedOps(db_with_cfh, db_with_cfh->db, 1);
|
||||
}
|
||||
|
@ -2481,6 +2489,10 @@ class Benchmark {
|
|||
for (int64_t i = 0; i < entries_per_batch_; ++i) {
|
||||
if (statuses[i].ok()) {
|
||||
++found;
|
||||
} else if (!statuses[i].IsNotFound()) {
|
||||
fprintf(stderr, "MultiGet returned an error: %s\n",
|
||||
statuses[i].ToString().c_str());
|
||||
abort();
|
||||
}
|
||||
}
|
||||
thread->stats.FinishedOps(nullptr, db, entries_per_batch_);
|
||||
|
@ -2920,8 +2932,13 @@ class Benchmark {
|
|||
DB* db = SelectDB(thread);
|
||||
GenerateKeyFromInt(thread->rand.Next() % FLAGS_num, FLAGS_num, &key);
|
||||
|
||||
if (db->Get(options, key, &value).ok()) {
|
||||
found++;
|
||||
auto status = db->Get(options, key, &value);
|
||||
if (status.ok()) {
|
||||
++found;
|
||||
} else if (!status.IsNotFound()) {
|
||||
fprintf(stderr,
|
||||
"Get returned an error: %s\n" status.ToString().c_str());
|
||||
abort();
|
||||
}
|
||||
|
||||
Status s = db->Put(write_options_, key, gen.Generate(value_size_));
|
||||
|
@ -2954,9 +2971,13 @@ class Benchmark {
|
|||
DB* db = SelectDB(thread);
|
||||
GenerateKeyFromInt(thread->rand.Next() % FLAGS_num, FLAGS_num, &key);
|
||||
|
||||
// Get the existing value
|
||||
if (db->Get(options, key, &value).ok()) {
|
||||
found++;
|
||||
auto status = db->Get(options, key, &value);
|
||||
if (status.ok()) {
|
||||
++found;
|
||||
} else if (!status.IsNotFound()) {
|
||||
fprintf(stderr,
|
||||
"Get returned an error: %s\n" status.ToString().c_str());
|
||||
abort();
|
||||
} else {
|
||||
// If not existing, then just assume an empty string of data
|
||||
value.clear();
|
||||
|
|
Loading…
Reference in a new issue