summaryrefslogtreecommitdiff
path: root/src/mongo/db/repl/mock_repl_coord_server_fixture.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/repl/mock_repl_coord_server_fixture.cpp')
-rw-r--r--src/mongo/db/repl/mock_repl_coord_server_fixture.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/mongo/db/repl/mock_repl_coord_server_fixture.cpp b/src/mongo/db/repl/mock_repl_coord_server_fixture.cpp
index bc8704c8622..9a76ffc13b4 100644
--- a/src/mongo/db/repl/mock_repl_coord_server_fixture.cpp
+++ b/src/mongo/db/repl/mock_repl_coord_server_fixture.cpp
@@ -47,6 +47,7 @@
#include "mongo/db/repl/storage_interface_mock.h"
#include "mongo/db/service_context.h"
#include "mongo/db/service_context_d_test_fixture.h"
+#include "mongo/db/storage/snapshot_manager.h"
namespace mongo {
@@ -90,6 +91,14 @@ void MockReplCoordServerFixture::setUp() {
repl::DropPendingCollectionReaper::set(
service,
std::make_unique<repl::DropPendingCollectionReaper>(repl::StorageInterface::get(service)));
+
+ // Set a committed snapshot so that we can perform majority reads.
+ WriteUnitOfWork wuow{_opCtx.get()};
+ if (auto snapshotManager =
+ _opCtx->getServiceContext()->getStorageEngine()->getSnapshotManager()) {
+ snapshotManager->setCommittedSnapshot(repl::getNextOpTime(_opCtx.get()).getTimestamp());
+ }
+ wuow.commit();
}
void MockReplCoordServerFixture::insertOplogEntry(const repl::OplogEntry& entry) {