From e686caffec20b7d0a1f4da4ac598d3d86048f87d Mon Sep 17 00:00:00 2001 From: Yanqin Jin Date: Mon, 7 Jan 2019 16:44:52 -0800 Subject: [PATCH] Remove unnecessary assersion in AtomicFlushStressTest::TestCheckpoint (#4846) Summary: as titled. We can remove the assersion because we do not perform verification in AtomicFlushStressTest::TestCheckpoint for similar reasons to TestGet, TestPut, etc. Therefore, we override TestCheckpoint in AtomicFlushStressTest so that the assertion `rand_column_families.size() == rand_keys.size()' is removed, and we do not verify the DB in this function. Pull Request resolved: https://github.com/facebook/rocksdb/pull/4846 Differential Revision: D13583377 Pulled By: riversand963 fbshipit-source-id: 03647f3da67e27a397413fd666e3bb43003bf596 --- tools/db_stress.cc | 52 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/tools/db_stress.cc b/tools/db_stress.cc index 0e1956259..8682fbf38 100644 --- a/tools/db_stress.cc +++ b/tools/db_stress.cc @@ -3759,6 +3759,58 @@ class AtomicFlushStressTest : public StressTest { return s; } +#ifdef ROCKSDB_LITE + virtual Status TestCheckpoint( + ThreadState* /* thread */, + const std::vector& /* rand_column_families */, + const std::vector& /* rand_keys */) { + assert(false); + fprintf(stderr, + "RocksDB lite does not support " + "TestCheckpoint\n"); + std::terminate(); + } +#else + virtual Status TestCheckpoint( + ThreadState* thread, const std::vector& /* rand_column_families */, + const std::vector& /* rand_keys */) { + std::string checkpoint_dir = + FLAGS_db + "/.checkpoint" + ToString(thread->tid); + DestroyDB(checkpoint_dir, Options()); + Checkpoint* checkpoint = nullptr; + Status s = Checkpoint::Create(db_, &checkpoint); + if (s.ok()) { + s = checkpoint->CreateCheckpoint(checkpoint_dir); + } + std::vector cf_handles; + DB* checkpoint_db = nullptr; + if (s.ok()) { + delete checkpoint; + checkpoint = nullptr; + Options options(options_); + options.listeners.clear(); + std::vector cf_descs; + // TODO(ajkr): `column_family_names_` is not safe to access here when + // `clear_column_family_one_in != 0`. But we can't easily switch to + // `ListColumnFamilies` to get names because it won't necessarily give + // the same order as `column_family_names_`. + if (FLAGS_clear_column_family_one_in == 0) { + for (const auto& name : column_family_names_) { + cf_descs.emplace_back(name, ColumnFamilyOptions(options)); + } + s = DB::OpenForReadOnly(DBOptions(options), checkpoint_dir, cf_descs, + &cf_handles, &checkpoint_db); + } + } + DestroyDB(checkpoint_dir, Options()); + if (!s.ok()) { + fprintf(stderr, "A checkpoint operation failed with: %s\n", + s.ToString().c_str()); + } + return s; + } +#endif // !ROCKSDB_LITE + virtual void VerifyDb(ThreadState* thread) const { ReadOptions options(FLAGS_verify_checksum, true); // We must set total_order_seek to true because we are doing a SeekToFirst