diff --git a/db_stress_tool/db_stress_driver.cc b/db_stress_tool/db_stress_driver.cc index 6bf46861f..00c007f08 100644 --- a/db_stress_tool/db_stress_driver.cc +++ b/db_stress_tool/db_stress_driver.cc @@ -117,6 +117,10 @@ bool RunStressTest(StressTest* stress) { } } + // This is after the verification step to avoid making all those `Get()`s + // and `MultiGet()`s contend on the DB-wide trace mutex. + stress->TrackExpectedState(&shared); + now = clock->NowMicros(); fprintf(stdout, "%s Starting database operations\n", clock->TimeToString(now / 1000000).c_str()); diff --git a/db_stress_tool/db_stress_test_base.cc b/db_stress_tool/db_stress_test_base.cc index f68092926..84922ccb2 100644 --- a/db_stress_tool/db_stress_test_base.cc +++ b/db_stress_tool/db_stress_test_base.cc @@ -310,15 +310,6 @@ void StressTest::FinishInitDb(SharedState* shared) { } } - if ((FLAGS_sync_fault_injection || FLAGS_disable_wal) && IsStateTracked()) { - Status s = shared->SaveAtAndAfter(db_); - if (!s.ok()) { - fprintf(stderr, "Error enabling history tracing: %s\n", - s.ToString().c_str()); - exit(1); - } - } - if (FLAGS_enable_compaction_filter) { auto* compaction_filter_factory = reinterpret_cast( @@ -333,6 +324,17 @@ void StressTest::FinishInitDb(SharedState* shared) { } } +void StressTest::TrackExpectedState(SharedState* shared) { + if ((FLAGS_sync_fault_injection || FLAGS_disable_wal) && IsStateTracked()) { + Status s = shared->SaveAtAndAfter(db_); + if (!s.ok()) { + fprintf(stderr, "Error enabling history tracing: %s\n", + s.ToString().c_str()); + exit(1); + } + } +} + bool StressTest::VerifySecondaries() { #ifndef ROCKSDB_LITE if (FLAGS_test_secondary) { diff --git a/db_stress_tool/db_stress_test_base.h b/db_stress_tool/db_stress_test_base.h index 60ecf46c1..786ace4ee 100644 --- a/db_stress_tool/db_stress_test_base.h +++ b/db_stress_tool/db_stress_test_base.h @@ -34,6 +34,8 @@ class StressTest { // dependency with `SharedState`. virtual void FinishInitDb(SharedState*); + void TrackExpectedState(SharedState* shared); + // Return false if verification fails. bool VerifySecondaries();