Skip to content

Commit

Permalink
Clean up secondary column families alongside primary column families (#…
Browse files Browse the repository at this point in the history
…13343)

Summary:
This is a continuation of #13338, which aims to address crash test failures caused by #13281.

This PR attempts to address the TSAN failures.

I searched for wherever we call `column_families_.clear()` and made sure that we also clear the secondary column families as well. I made a helper method since it is easy to forget to clear both sets of column families.

Pull Request resolved: #13343

Test Plan: Monitor recurring crash test results.

Reviewed By: cbi42

Differential Revision: D68790580

Pulled By: archang19

fbshipit-source-id: 96ed758a21545dd20181b8db71b81dd660546e18
  • Loading branch information
archang19 authored and facebook-github-bot committed Jan 28, 2025
1 parent b8d915c commit f37ce33
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 20 deletions.
35 changes: 15 additions & 20 deletions db_stress_tool/db_stress_test_base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -104,22 +104,26 @@ StressTest::StressTest()
}

void StressTest::CleanUp() {
for (auto cf : column_families_) {
delete cf;
}
column_families_.clear();
CleanUpColumnFamilies();
if (db_) {
db_->Close();
}
delete db_;
db_ = nullptr;

delete secondary_db_;
secondary_db_ = nullptr;
}

void StressTest::CleanUpColumnFamilies() {
for (auto cf : column_families_) {
delete cf;
}
column_families_.clear();
for (auto* cf : secondary_cfhs_) {
delete cf;
}
secondary_cfhs_.clear();
delete secondary_db_;
secondary_db_ = nullptr;
}

std::shared_ptr<Cache> StressTest::NewCache(size_t capacity,
Expand Down Expand Up @@ -735,10 +739,7 @@ void StressTest::PreloadDbAndReopenAsReadOnly(int64_t number_of_keys,
s = db_->Flush(FlushOptions(), column_families_);
}
if (s.ok()) {
for (auto cf : column_families_) {
delete cf;
}
column_families_.clear();
CleanUpColumnFamilies();
delete db_;
db_ = nullptr;
txn_db_ = nullptr;
Expand Down Expand Up @@ -3581,10 +3582,7 @@ void StressTest::Open(SharedState* shared, bool reopen) {
// clean state before executing queries.
s = db_->GetRootDB()->WaitForCompact(WaitForCompactOptions());
if (!s.ok()) {
for (auto cf : column_families_) {
delete cf;
}
column_families_.clear();
CleanUpColumnFamilies();
delete db_;
db_ = nullptr;
delete secondary_db_;
Expand Down Expand Up @@ -3755,15 +3753,12 @@ void StressTest::Reopen(ThreadState* thread) {
}
assert(!write_prepared || bg_canceled);

for (auto cf : column_families_) {
delete cf;
}
column_families_.clear();
CleanUpColumnFamilies();

// Currently reopen does not restore expected state
// with potential data loss in mind like the first open before
// crash-recovery verification does. Therefore it always expects no data loss
// and we should ensure no data loss in testing.
// crash-recovery verification does. Therefore it always expects no data
// loss and we should ensure no data loss in testing.
// TODO(hx235): eliminate the FlushWAL(true /* sync */)/SyncWAL() below
if (!FLAGS_disable_wal) {
Status s;
Expand Down
2 changes: 2 additions & 0 deletions db_stress_tool/db_stress_test_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,8 @@ class StressTest {
std::string& ts_str, Slice& ts_slice,
ReadOptions& read_opts);

void CleanUpColumnFamilies();

std::shared_ptr<Cache> cache_;
std::shared_ptr<Cache> compressed_cache_;
std::shared_ptr<const FilterPolicy> filter_policy_;
Expand Down

0 comments on commit f37ce33

Please sign in to comment.