From fcb31016e93aedc15af6adade7f36d77041b7a15 Mon Sep 17 00:00:00 2001 From: Andrew Kryczka Date: Tue, 22 May 2018 10:50:09 -0700 Subject: [PATCH] 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 --- tools/db_stress.cc | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/tools/db_stress.cc b/tools/db_stress.cc index 799dd7884..579515304 100644 --- a/tools/db_stress.cc +++ b/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= if (FLAGS_db.empty()) {