diff options
author | Benety Goh <benety@mongodb.com> | 2020-08-18 16:17:47 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-08-18 21:01:01 +0000 |
commit | 8982a53c39f6e1a3f29a17f1877f2e85dd62b73f (patch) | |
tree | aaff8eba1273cc9dc230556c9dc4addc5ed173ad /src/mongo/dbtests/storage_timestamp_tests.cpp | |
parent | cad2d5b3ebfe416024d0276c410302e98f2b5037 (diff) | |
download | mongo-8982a53c39f6e1a3f29a17f1877f2e85dd62b73f.tar.gz |
SERVER-50366 fix StorageTimestampTests for resumable index builds
Diffstat (limited to 'src/mongo/dbtests/storage_timestamp_tests.cpp')
-rw-r--r-- | src/mongo/dbtests/storage_timestamp_tests.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/mongo/dbtests/storage_timestamp_tests.cpp b/src/mongo/dbtests/storage_timestamp_tests.cpp index cc9bc42645d..a43b1c31058 100644 --- a/src/mongo/dbtests/storage_timestamp_tests.cpp +++ b/src/mongo/dbtests/storage_timestamp_tests.cpp @@ -2181,6 +2181,11 @@ public: // Save the pre-state idents so we can capture the specific ident related to index // creation. origIdents = durableCatalog->getAllIdents(_opCtx); + + // Ensure we have a committed snapshot to avoid ReadConcernMajorityNotAvailableYet + // error at the beginning of the the collection scan phase. + auto snapshotManager = storageEngine->getSnapshotManager(); + snapshotManager->setCommittedSnapshot(insertTimestamp.asTimestamp()); } DBDirectClient client(_opCtx); @@ -2284,6 +2289,11 @@ public: presentTerm)); wuow.commit(); ASSERT_EQ(1, itCount(autoColl.getCollection())); + + // Ensure we have a committed snapshot to avoid ReadConcernMajorityNotAvailableYet + // error at the beginning of the the collection scan phase. + auto snapshotManager = storageEngine->getSnapshotManager(); + snapshotManager->setCommittedSnapshot(insertTimestamp.asTimestamp()); } DBDirectClient client(_opCtx); @@ -2413,6 +2423,11 @@ public: // Save the pre-state idents so we can capture the specific ident related to index // creation. origIdents = durableCatalog->getAllIdents(_opCtx); + + // Ensure we have a committed snapshot to avoid ReadConcernMajorityNotAvailableYet + // error at the beginning of the the collection scan phase. + auto snapshotManager = storageEngine->getSnapshotManager(); + snapshotManager->setCommittedSnapshot(insertTimestamp2.asTimestamp()); } { @@ -2947,6 +2962,20 @@ public: class TimestampIndexOplogApplicationOnPrimary : public StorageTimestampTest { public: void run() { + // Index builds expect a non-empty oplog and a valid committed snapshot. + { + Lock::GlobalLock lk(_opCtx, MODE_IX); + WriteUnitOfWork wuow(_opCtx); + auto service = _opCtx->getServiceContext(); + service->getOpObserver()->onOpMessage(_opCtx, BSONObj()); + wuow.commit(); + + auto snapshotManager = service->getStorageEngine()->getSnapshotManager(); + auto lastAppliedOpTime = + repl::ReplicationCoordinator::get(service)->getMyLastAppliedOpTime(); + snapshotManager->setCommittedSnapshot(lastAppliedOpTime.getTimestamp()); + } + // In order for oplog application to assign timestamps, we must be in non-replicated mode // and disable document validation. repl::UnreplicatedWritesBlock uwb(_opCtx); |