Avoid single-deleting merge operands in db_stress

Summary:
I repro'd some of the "unexpected value" failures showing up in our CI lately and they always happened on keys that have a mix of single deletes and merge operands. The `SingleDelete()` API comment mentions it's incompatible with `Merge()`, so this PR prevents `db_stress` from mixing them.
Closes https://github.com/facebook/rocksdb/pull/3878

Differential Revision: D8097346

Pulled By: ajkr

fbshipit-source-id: 357a48c6a31156f4f8db3ce565638ad924c437a1
main
Andrew Kryczka 7 years ago committed by Facebook Github Bot
parent 3db1ada3bf
commit fcb31016e9
  1. 13
      tools/db_stress.cc

@ -2126,9 +2126,12 @@ class StressTest {
Slice v(value, sz);
if (!FLAGS_test_batches_snapshots) {
// If the chosen key does not allow overwrite and it already
// exists, choose another key.
// exists, choose another key. Also avoid using merge operands in
// no-overwrite positions (where single delete will be called later),
// as those features have undefined behavior when used together.
while (!shared->AllowsOverwrite(rand_column_family, rand_key) &&
shared->Exists(rand_column_family, rand_key)) {
(FLAGS_use_merge ||
shared->Exists(rand_column_family, rand_key))) {
l.reset();
rand_key = thread->rand.Next() % max_key;
rand_column_family = thread->rand.Next() % FLAGS_column_families;
@ -2919,6 +2922,12 @@ int main(int argc, char** argv) {
kValueMaxLen / kRandomValueMaxFactor);
exit(1);
}
if (FLAGS_use_merge && FLAGS_nooverwritepercent == 100) {
fprintf(
stderr,
"Error: nooverwritepercent must not be 100 when using merge operands");
exit(1);
}
// Choose a location for the test database if none given with --db=<path>
if (FLAGS_db.empty()) {

Loading…
Cancel
Save