diff --git a/db_stress_tool/db_stress_test_base.cc b/db_stress_tool/db_stress_test_base.cc index ec2f14523..8930bf0ae 100644 --- a/db_stress_tool/db_stress_test_base.cc +++ b/db_stress_tool/db_stress_test_base.cc @@ -298,17 +298,8 @@ void StressTest::FinishInitDb(SharedState* shared) { clock_->TimeToString(now / 1000000).c_str(), FLAGS_max_key); PreloadDbAndReopenAsReadOnly(FLAGS_max_key, shared); } - if (FLAGS_enable_compaction_filter) { - auto* compaction_filter_factory = - reinterpret_cast( - options_.compaction_filter_factory.get()); - assert(compaction_filter_factory); - compaction_filter_factory->SetSharedState(shared); - fprintf(stdout, "Compaction filter factory: %s\n", - compaction_filter_factory->Name()); - } - if (shared->HasHistory() && IsStateTracked()) { + if (shared->HasHistory()) { // The way it works right now is, if there's any history, that means the // previous run mutating the DB had all its operations traced, in which case // we should always be able to `Restore()` the expected values to match the @@ -329,6 +320,19 @@ void StressTest::FinishInitDb(SharedState* shared) { exit(1); } } + + if (FLAGS_enable_compaction_filter) { + auto* compaction_filter_factory = + reinterpret_cast( + options_.compaction_filter_factory.get()); + assert(compaction_filter_factory); + // This must be called only after any potential `SharedState::Restore()` has + // completed in order for the `compaction_filter_factory` to operate on the + // correct latest values file. + compaction_filter_factory->SetSharedState(shared); + fprintf(stdout, "Compaction filter factory: %s\n", + compaction_filter_factory->Name()); + } } bool StressTest::VerifySecondaries() { diff --git a/db_stress_tool/expected_state.cc b/db_stress_tool/expected_state.cc index 075517f6f..b72482a7c 100644 --- a/db_stress_tool/expected_state.cc +++ b/db_stress_tool/expected_state.cc @@ -326,6 +326,8 @@ bool FileExpectedStateManager::HasHistory() { #ifndef ROCKSDB_LITE +namespace { + // An `ExpectedStateTraceRecordHandler` applies a configurable number of // write operation trace records to the configured expected state. It is used in // `FileExpectedStateManager::Restore()` to sync the expected state with the @@ -429,6 +431,8 @@ class ExpectedStateTraceRecordHandler : public TraceRecord::Handler, ExpectedState* state_; }; +} // anonymous namespace + Status FileExpectedStateManager::Restore(DB* db) { assert(HasHistory()); SequenceNumber seqno = db->GetLatestSequenceNumber();