diff options
Diffstat (limited to 'src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine_test.cpp')
-rw-r--r-- | src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine_test.cpp | 33 |
1 files changed, 13 insertions, 20 deletions
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine_test.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine_test.cpp index 5f7da06d557..18f8fa87b96 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine_test.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine_test.cpp @@ -282,29 +282,25 @@ TEST_F(WiredTigerKVEngineTest, TestOplogTruncation) { auto severityGuard = unittest::MinimumLoggedSeverityGuard{logv2::LogComponent::kStorage, logv2::LogSeverity::Debug(3)}; + // Set syncdelay before starting the checkpoint thread, otherwise it can observe the default + // checkpoint frequency of 60 seconds, causing the test to fail due to a 10 second timeout. + storageGlobalParams.syncdelay.store(1); + std::unique_ptr<Checkpointer> checkpointer = std::make_unique<Checkpointer>(); checkpointer->go(); + // If the test fails we want to ensure the checkpoint thread shuts down to avoid accessing the + // storage engine during shutdown. + ON_BLOCK_EXIT([&] { + checkpointer->shutdown({ErrorCodes::ShutdownInProgress, "Test finished"}); + }); + auto opCtxPtr = _makeOperationContext(); // The initial data timestamp has to be set to take stable checkpoints. The first stable // timestamp greater than this will also trigger a checkpoint. The following loop of the // CheckpointThread will observe the new `syncdelay` value. _helper.getWiredTigerKVEngine()->setInitialDataTimestamp(Timestamp(1, 1)); - - // Ignore data race on this variable when running with TSAN, this is only an issue in this - // unittest and not in mongod - []() -#if defined(__has_feature) -#if __has_feature(thread_sanitizer) - __attribute__((no_sanitize("thread"))) -#endif -#endif - { - storageGlobalParams.syncdelay = 1; - } - (); - // Simulate the callback that queries config.transactions for the oldest active transaction. boost::optional<Timestamp> oldestActiveTxnTimestamp; AtomicWord<bool> callbackShouldFail{false}; @@ -344,10 +340,9 @@ TEST_F(WiredTigerKVEngineTest, TestOplogTruncation) { } LOGV2(22367, - "Expected the pinned oplog to advance. Expected value: {newPinned} Published value: " - "{engine_getOplogNeededForCrashRecovery}", - "newPinned"_attr = newPinned, - "engine_getOplogNeededForCrashRecovery"_attr = + "Expected the pinned oplog to advance.", + "expectedValue"_attr = newPinned, + "publishedValue"_attr = _helper.getWiredTigerKVEngine()->getOplogNeededForCrashRecovery()); FAIL(""); }; @@ -378,8 +373,6 @@ TEST_F(WiredTigerKVEngineTest, TestOplogTruncation) { _helper.getWiredTigerKVEngine()->setStableTimestamp(Timestamp(30, 1), false); callbackShouldFail.store(false); assertPinnedMovesSoon(Timestamp(40, 1)); - - checkpointer->shutdown({ErrorCodes::ShutdownInProgress, "Test finished"}); } TEST_F(WiredTigerKVEngineTest, IdentDrop) { |