From 50895e5f0dd293602b7ccb5d284e6143715a27e5 Mon Sep 17 00:00:00 2001 From: Yanqin Jin Date: Tue, 30 Oct 2018 17:27:57 -0700 Subject: [PATCH] Update manual flush stress test (#4608) Summary: Originally, the manual flush calls in db_stress flushes only a single column family, which is not sufficient when atomic flush is enabled. With atomic flush, we should call `Flush(flush_opts, cfhs)` to better test this new feature. Specifically, we manuall flush all column families so that database verification is easier. Pull Request resolved: https://github.com/facebook/rocksdb/pull/4608 Differential Revision: D12849160 Pulled By: riversand963 fbshipit-source-id: ae1f0dd825247b42c0aba520a5c967335102c876 --- tools/db_stress.cc | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/tools/db_stress.cc b/tools/db_stress.cc index 4c3e98658..941216a41 100644 --- a/tools/db_stress.cc +++ b/tools/db_stress.cc @@ -1967,15 +1967,6 @@ class StressTest { auto column_family = column_families_[rand_column_family]; - if (FLAGS_flush_one_in > 0 && - thread->rand.Uniform(FLAGS_flush_one_in) == 0) { - FlushOptions flush_opts; - Status status = db_->Flush(flush_opts, column_family); - if (!status.ok()) { - fprintf(stdout, "Unable to perform Flush(): %s\n", status.ToString().c_str()); - } - } - if (FLAGS_compact_range_one_in > 0 && thread->rand.Uniform(FLAGS_compact_range_one_in) == 0) { int64_t end_key_num; @@ -1999,6 +1990,21 @@ class StressTest { std::vector rand_column_families = GenerateColumnFamilies(FLAGS_column_families, rand_column_family); + + if (FLAGS_flush_one_in > 0 && + thread->rand.Uniform(FLAGS_flush_one_in) == 0) { + FlushOptions flush_opts; + std::vector cfhs; + std::for_each( + rand_column_families.begin(), rand_column_families.end(), + [this, &cfhs](int k) { cfhs.push_back(column_families_[k]); }); + Status status = db_->Flush(flush_opts, cfhs); + if (!status.ok()) { + fprintf(stdout, "Unable to perform Flush(): %s\n", + status.ToString().c_str()); + } + } + std::vector rand_keys = GenerateKeys(rand_key); if (FLAGS_ingest_external_file_one_in > 0 &&