#ifdef GFLAGS
#include "db_stress_tool/db_stress_common.h"
+#include "file/file_util.h"
namespace ROCKSDB_NAMESPACE {
class CfConsistencyStressTest : public StressTest {
return column_families_[thread->rand.Next() % column_families_.size()];
}
-#ifdef ROCKSDB_LITE
- Status TestCheckpoint(ThreadState* /* thread */,
- const std::vector<int>& /* rand_column_families */,
- const std::vector<int64_t>& /* rand_keys */) override {
- assert(false);
- fprintf(stderr,
- "RocksDB lite does not support "
- "TestCheckpoint\n");
- std::terminate();
- }
-#else
- Status TestCheckpoint(ThreadState* thread,
- const std::vector<int>& /* rand_column_families */,
- const std::vector<int64_t>& /* rand_keys */) override {
- std::string checkpoint_dir =
- FLAGS_db + "/.checkpoint" + ToString(thread->tid);
-
- // We need to clear DB including manifest files, so make a copy
- Options opt_copy = options_;
- opt_copy.env = db_stress_env->target();
- DestroyDB(checkpoint_dir, opt_copy);
-
- Checkpoint* checkpoint = nullptr;
- Status s = Checkpoint::Create(db_, &checkpoint);
- if (s.ok()) {
- s = checkpoint->CreateCheckpoint(checkpoint_dir);
- }
- std::vector<ColumnFamilyHandle*> cf_handles;
- DB* checkpoint_db = nullptr;
- if (s.ok()) {
- delete checkpoint;
- checkpoint = nullptr;
- Options options(options_);
- options.listeners.clear();
- std::vector<ColumnFamilyDescriptor> 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);
- }
- }
- if (checkpoint_db != nullptr) {
- for (auto cfh : cf_handles) {
- delete cfh;
- }
- cf_handles.clear();
- delete checkpoint_db;
- checkpoint_db = nullptr;
- }
- DestroyDB(checkpoint_dir, opt_copy);
- if (!s.ok()) {
- fprintf(stderr, "A checkpoint operation failed with: %s\n",
- s.ToString().c_str());
- }
- return s;
- }
-#endif // !ROCKSDB_LITE
-
void VerifyDb(ThreadState* thread) const override {
ReadOptions options(FLAGS_verify_checksum, true);
// We must set total_order_seek to true because we are doing a SeekToFirst