Skip to content

Commit

Permalink
Rename cmp_db and cmp_cfhs
Browse files Browse the repository at this point in the history
  • Loading branch information
archang19 committed Jan 8, 2025
1 parent 553c4ef commit 8f637f9
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 23 deletions.
10 changes: 5 additions & 5 deletions db_stress_tool/cf_consistency_stress.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1040,17 +1040,17 @@ class CfConsistencyStressTest : public StressTest {
assert(thread);
Status status;

DB* db_ptr = cmp_db_ ? cmp_db_ : db_;
const auto& cfhs = cmp_db_ ? cmp_cfhs_ : column_families_;
DB* db_ptr = secondary_db_ ? secondary_db_ : db_;
const auto& cfhs = secondary_db_ ? secondary_cfhs_ : column_families_;

// Take a snapshot to preserve the state of primary db.
ManagedSnapshot snapshot_guard(db_);

SharedState* shared = thread->shared;
assert(shared);

if (cmp_db_) {
status = cmp_db_->TryCatchUpWithPrimary();
if (secondary_db_) {
status = secondary_db_->TryCatchUpWithPrimary();
if (!status.ok()) {
fprintf(stderr, "TryCatchUpWithPrimary: %s\n",
status.ToString().c_str());
Expand Down Expand Up @@ -1083,7 +1083,7 @@ class CfConsistencyStressTest : public StressTest {
// `FLAGS_rate_limit_user_ops` to avoid slowing any validation.
ReadOptions ropts(FLAGS_verify_checksum, true);
ropts.total_order_seek = true;
if (nullptr == cmp_db_) {
if (nullptr == secondary_db_) {
ropts.snapshot = snapshot_guard.snapshot();
}
uint32_t crc = 0;
Expand Down
13 changes: 7 additions & 6 deletions db_stress_tool/db_stress_test_base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ StressTest::StressTest()
new_column_family_name_(1),
num_times_reopened_(0),
db_preload_finished_(false),
cmp_db_(nullptr),
secondary_db_(nullptr),
is_db_stopped_(false) {
if (FLAGS_destroy_db_initially) {
std::vector<std::string> files;
Expand Down Expand Up @@ -114,11 +114,11 @@ void StressTest::CleanUp() {
delete db_;
db_ = nullptr;

for (auto* cf : cmp_cfhs_) {
for (auto* cf : secondary_cfhs_) {
delete cf;
}
cmp_cfhs_.clear();
delete cmp_db_;
secondary_cfhs_.clear();
delete secondary_db_;
}

std::shared_ptr<Cache> StressTest::NewCache(size_t capacity,
Expand Down Expand Up @@ -3696,9 +3696,10 @@ void StressTest::Open(SharedState* shared, bool reopen) {
tmp_opts.env = db_stress_env;
const std::string& secondary_path = FLAGS_secondaries_base;
s = DB::OpenAsSecondary(tmp_opts, FLAGS_db, secondary_path,
cf_descriptors, &cmp_cfhs_, &cmp_db_);
cf_descriptors, &secondary_cfhs_, &secondary_db_);
assert(s.ok());
assert(cmp_cfhs_.size() == static_cast<size_t>(FLAGS_column_families));
assert(secondary_cfhs_.size() ==
static_cast<size_t>(FLAGS_column_families));
}
} else {
DBWithTTL* db_with_ttl;
Expand Down
5 changes: 2 additions & 3 deletions db_stress_tool/db_stress_test_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -412,9 +412,8 @@ class StressTest {
std::atomic<bool> db_preload_finished_;
std::shared_ptr<SstQueryFilterConfigsManager::Factory> sqfc_factory_;

// Fields used for continuous verification from another thread
DB* cmp_db_;
std::vector<ColumnFamilyHandle*> cmp_cfhs_;
DB* secondary_db_;
std::vector<ColumnFamilyHandle*> secondary_cfhs_;
bool is_db_stopped_;
};

Expand Down
21 changes: 12 additions & 9 deletions db_stress_tool/no_batched_ops_stress.cc
Original file line number Diff line number Diff line change
Expand Up @@ -334,11 +334,11 @@ class NonBatchedOpsStressTest : public StressTest {
}

void ContinuouslyVerifyDb(ThreadState* thread) const override {
if (!cmp_db_) {
if (!secondary_db_) {
return;
}
assert(cmp_db_);
assert(!cmp_cfhs_.empty());
assert(secondary_db_);
assert(!secondary_cfhs_.empty());

auto* shared = thread->shared;
assert(shared);
Expand All @@ -362,7 +362,7 @@ class NonBatchedOpsStressTest : public StressTest {
pre_read_expected_values.push_back(shared->Get(0, i));
}

Status s = cmp_db_->TryCatchUpWithPrimary();
Status s = secondary_db_->TryCatchUpWithPrimary();
if (!s.ok()) {
assert(false);
exit(1);
Expand Down Expand Up @@ -433,22 +433,24 @@ class NonBatchedOpsStressTest : public StressTest {

static Random64 rand64(shared->GetSeed());

for (auto* handle : cmp_cfhs_) {
for (auto* handle : secondary_cfhs_) {
if (thread->rand.OneInOpt(3)) {
// Use Get()
uint64_t key = rand64.Uniform(static_cast<uint64_t>(max_key));
std::string key_str = Key(key);
std::string value;
std::string key_ts;
s = cmp_db_->Get(read_opts, handle, key_str, &value,
FLAGS_user_timestamp_size > 0 ? &key_ts : nullptr);
s = secondary_db_->Get(
read_opts, handle, key_str, &value,
FLAGS_user_timestamp_size > 0 ? &key_ts : nullptr);
s.PermitUncheckedError();
} else if (!FLAGS_inplace_update_support) {
// The combination of inplace_update_support=true and backward iteration
// is not allowed

// Use range scan
std::unique_ptr<Iterator> iter(cmp_db_->NewIterator(read_opts, handle));
std::unique_ptr<Iterator> iter(
secondary_db_->NewIterator(read_opts, handle));
uint32_t rnd = (thread->rand.Next()) % 4;
if (0 == rnd) {
// SeekToFirst() + Next()*5
Expand Down Expand Up @@ -480,7 +482,8 @@ class NonBatchedOpsStressTest : public StressTest {
}
} else {
uint32_t crc = 0;
std::unique_ptr<Iterator> it(cmp_db_->NewIterator(read_opts, handle));
std::unique_ptr<Iterator> it(
secondary_db_->NewIterator(read_opts, handle));
s = checksum_column_family(it.get(), &crc);
if (!s.ok()) {
fprintf(stderr, "Computing checksum of default cf: %s\n",
Expand Down

0 comments on commit 8f637f9

Please sign in to comment.