diff --git a/db_stress_tool/db_stress_test_base.cc b/db_stress_tool/db_stress_test_base.cc index 9c94d15e5238609b63fcb0745ad2421a49afe84e..d2232ccfb28abd626d1e49f2c573af11643252b7 100644 --- a/db_stress_tool/db_stress_test_base.cc +++ b/db_stress_tool/db_stress_test_base.cc @@ -1335,10 +1335,34 @@ Status StressTest::TestCheckpoint(ThreadState* thread, DestroyDB(checkpoint_dir, tmp_opts); + if (db_stress_env->FileExists(checkpoint_dir).ok()) { + // If the directory might still exist, try to delete the files one by one. + // Likely a trash file is still there. + Status my_s = test::DestroyDir(db_stress_env, checkpoint_dir); + if (!my_s.ok()) { + fprintf(stderr, "Fail to destory directory before checkpoint: %s", + my_s.ToString().c_str()); + } + } + Checkpoint* checkpoint = nullptr; Status s = Checkpoint::Create(db_, &checkpoint); if (s.ok()) { s = checkpoint->CreateCheckpoint(checkpoint_dir); + if (!s.ok()) { + fprintf(stderr, "Fail to create checkpoint to %s\n", + checkpoint_dir.c_str()); + std::vector files; + Status my_s = db_stress_env->GetChildren(checkpoint_dir, &files); + if (my_s.ok()) { + for (const auto& f : files) { + fprintf(stderr, " %s\n", f.c_str()); + } + } else { + fprintf(stderr, "Fail to get files under the directory to %s\n", + my_s.ToString().c_str()); + } + } } std::vector cf_handles; DB* checkpoint_db = nullptr; @@ -1391,11 +1415,11 @@ Status StressTest::TestCheckpoint(ThreadState* thread, checkpoint_db = nullptr; } - DestroyDB(checkpoint_dir, tmp_opts); - if (!s.ok()) { fprintf(stderr, "A checkpoint operation failed with: %s\n", s.ToString().c_str()); + } else { + DestroyDB(checkpoint_dir, tmp_opts); } return s; }