mirror of
https://github.com/facebook/rocksdb.git
synced 2024-11-26 16:30:56 +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);
|
int64_t key_rand = thread->rand.Next() & (pot - 1);
|
||||||
GenerateKeyFromInt(key_rand, FLAGS_num, &key);
|
GenerateKeyFromInt(key_rand, FLAGS_num, &key);
|
||||||
++read;
|
++read;
|
||||||
if (db->Get(options, key, &value).ok()) {
|
auto status = db->Get(options, key, &value);
|
||||||
|
if (status.ok()) {
|
||||||
++found;
|
++found;
|
||||||
|
} else if (!status.IsNotFound()) {
|
||||||
|
fprintf(stderr,
|
||||||
|
"Get returned an error: %s\n" status.ToString().c_str());
|
||||||
|
abort();
|
||||||
}
|
}
|
||||||
if (key_rand >= FLAGS_num) {
|
if (key_rand >= FLAGS_num) {
|
||||||
++nonexist;
|
++nonexist;
|
||||||
|
@ -2440,6 +2445,9 @@ class Benchmark {
|
||||||
}
|
}
|
||||||
if (s.ok()) {
|
if (s.ok()) {
|
||||||
found++;
|
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);
|
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) {
|
for (int64_t i = 0; i < entries_per_batch_; ++i) {
|
||||||
if (statuses[i].ok()) {
|
if (statuses[i].ok()) {
|
||||||
++found;
|
++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_);
|
thread->stats.FinishedOps(nullptr, db, entries_per_batch_);
|
||||||
|
@ -2920,8 +2932,13 @@ class Benchmark {
|
||||||
DB* db = SelectDB(thread);
|
DB* db = SelectDB(thread);
|
||||||
GenerateKeyFromInt(thread->rand.Next() % FLAGS_num, FLAGS_num, &key);
|
GenerateKeyFromInt(thread->rand.Next() % FLAGS_num, FLAGS_num, &key);
|
||||||
|
|
||||||
if (db->Get(options, key, &value).ok()) {
|
auto status = db->Get(options, key, &value);
|
||||||
found++;
|
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_));
|
Status s = db->Put(write_options_, key, gen.Generate(value_size_));
|
||||||
|
@ -2954,9 +2971,13 @@ class Benchmark {
|
||||||
DB* db = SelectDB(thread);
|
DB* db = SelectDB(thread);
|
||||||
GenerateKeyFromInt(thread->rand.Next() % FLAGS_num, FLAGS_num, &key);
|
GenerateKeyFromInt(thread->rand.Next() % FLAGS_num, FLAGS_num, &key);
|
||||||
|
|
||||||
// Get the existing value
|
auto status = db->Get(options, key, &value);
|
||||||
if (db->Get(options, key, &value).ok()) {
|
if (status.ok()) {
|
||||||
found++;
|
++found;
|
||||||
|
} else if (!status.IsNotFound()) {
|
||||||
|
fprintf(stderr,
|
||||||
|
"Get returned an error: %s\n" status.ToString().c_str());
|
||||||
|
abort();
|
||||||
} else {
|
} else {
|
||||||
// If not existing, then just assume an empty string of data
|
// If not existing, then just assume an empty string of data
|
||||||
value.clear();
|
value.clear();
|
||||||
|
|
Loading…
Reference in a new issue