diff options
author | Gregory Wlodarek <gregory.wlodarek@mongodb.com> | 2023-05-11 15:42:39 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2023-05-11 18:44:42 +0000 |
commit | e4ddf04d04f39b2e319ce30b1570a78d0bfa7173 (patch) | |
tree | fa08b10e1ca659e2c40b926cf1354dbd9a9f2d3a | |
parent | 1e233afdb0def2aed7521ae087b575c95245e257 (diff) | |
download | mongo-e4ddf04d04f39b2e319ce30b1570a78d0bfa7173.tar.gz |
SERVER-77029 Set syncdelay in TestOplogTruncation before starting the checkpoint thread
-rw-r--r-- | src/mongo/db/storage/checkpointer.cpp | 4 | ||||
-rw-r--r-- | src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine_test.cpp | 33 |
2 files changed, 17 insertions, 20 deletions
diff --git a/src/mongo/db/storage/checkpointer.cpp b/src/mongo/db/storage/checkpointer.cpp index 6b633075ae7..b3d249e1837 100644 --- a/src/mongo/db/storage/checkpointer.cpp +++ b/src/mongo/db/storage/checkpointer.cpp @@ -87,6 +87,10 @@ void Checkpointer::run() { // Wait for 'storageGlobalParams.syncdelay' seconds; or until either shutdown is // signaled or a checkpoint is triggered. + LOGV2_DEBUG(7702900, + 1, + "Checkpoint thread sleeping", + "duration"_attr = static_cast<std::int64_t>(storageGlobalParams.syncdelay)); _sleepCV.wait_for( lock, stdx::chrono::seconds(static_cast<std::int64_t>(storageGlobalParams.syncdelay)), 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) { |