diff options
author | Lingzhi Deng <lingzhi.deng@mongodb.com> | 2020-11-04 21:57:14 -0500 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-11-06 03:20:31 +0000 |
commit | ca3c18008bff68e2684ad5954452c6513f7a744e (patch) | |
tree | e280511f4948c0c146a39df33576ff39fae3f26b /src/mongo/db | |
parent | a53936d6b01f26babe3ac2be79be68e8334590b2 (diff) | |
download | mongo-ca3c18008bff68e2684ad5954452c6513f7a744e.tar.gz |
SERVER-52624: Remove useless setOplogCollectionName and getOplogCollectionName from LocalOplogInfo
Diffstat (limited to 'src/mongo/db')
30 files changed, 4 insertions, 64 deletions
diff --git a/src/mongo/db/auth/auth_op_observer_test.cpp b/src/mongo/db/auth/auth_op_observer_test.cpp index 6069ee02f13..2dad678cc7b 100644 --- a/src/mongo/db/auth/auth_op_observer_test.cpp +++ b/src/mongo/db/auth/auth_op_observer_test.cpp @@ -69,7 +69,6 @@ public: repl::ReplicationCoordinator::set( service, std::make_unique<repl::ReplicationCoordinatorMock>(service, createReplSettings())); - repl::setOplogCollectionName(service); repl::createOplog(opCtx.get()); // Ensure that we are primary. diff --git a/src/mongo/db/catalog/capped_utils_test.cpp b/src/mongo/db/catalog/capped_utils_test.cpp index 9bba12741bd..50c8b634197 100644 --- a/src/mongo/db/catalog/capped_utils_test.cpp +++ b/src/mongo/db/catalog/capped_utils_test.cpp @@ -66,8 +66,6 @@ void CappedUtilsTest::setUp() { ASSERT_OK(replCoord->setFollowerMode(repl::MemberState::RS_PRIMARY)); repl::ReplicationCoordinator::set(service, std::move(replCoord)); - repl::setOplogCollectionName(service); - _storage = std::make_unique<repl::StorageInterfaceImpl>(); } diff --git a/src/mongo/db/catalog/catalog_test_fixture.cpp b/src/mongo/db/catalog/catalog_test_fixture.cpp index bcc198f72a8..02591eb0937 100644 --- a/src/mongo/db/catalog/catalog_test_fixture.cpp +++ b/src/mongo/db/catalog/catalog_test_fixture.cpp @@ -54,7 +54,6 @@ void CatalogTestFixture::setUp() { // Set up oplog collection. If the WT storage engine is used, the oplog collection is expected // to exist when fetching the next opTime (LocalOplogInfo::getNextOpTimes) to use for a write. - repl::setOplogCollectionName(service); repl::createOplog(_opCtx.get()); } diff --git a/src/mongo/db/catalog/create_collection_test.cpp b/src/mongo/db/catalog/create_collection_test.cpp index e6df170d7b6..e8c36b94fcc 100644 --- a/src/mongo/db/catalog/create_collection_test.cpp +++ b/src/mongo/db/catalog/create_collection_test.cpp @@ -71,7 +71,6 @@ void CreateCollectionTest::setUp() { auto replCoord = std::make_unique<repl::ReplicationCoordinatorMock>(service); ASSERT_OK(replCoord->setFollowerMode(repl::MemberState::RS_PRIMARY)); repl::ReplicationCoordinator::set(service, std::move(replCoord)); - repl::setOplogCollectionName(service); _storage = std::make_unique<repl::StorageInterfaceImpl>(); } diff --git a/src/mongo/db/catalog/database_test.cpp b/src/mongo/db/catalog/database_test.cpp index 45a688b5caa..4badacce96f 100644 --- a/src/mongo/db/catalog/database_test.cpp +++ b/src/mongo/db/catalog/database_test.cpp @@ -89,7 +89,6 @@ void DatabaseTest::setUp() { // Set up ReplicationCoordinator and create oplog. repl::ReplicationCoordinator::set(service, std::make_unique<repl::ReplicationCoordinatorMock>(service)); - repl::setOplogCollectionName(service); repl::createOplog(_opCtx.get()); // Ensure that we are primary. diff --git a/src/mongo/db/catalog/drop_database_test.cpp b/src/mongo/db/catalog/drop_database_test.cpp index 8ee0a7bf6b2..e5b68aa013e 100644 --- a/src/mongo/db/catalog/drop_database_test.cpp +++ b/src/mongo/db/catalog/drop_database_test.cpp @@ -147,7 +147,6 @@ void DropDatabaseTest::setUp() { auto replCoord = std::make_unique<repl::ReplicationCoordinatorMock>(service); _replCoord = replCoord.get(); repl::ReplicationCoordinator::set(service, std::move(replCoord)); - repl::setOplogCollectionName(service); repl::createOplog(_opCtx.get()); // Ensure that we are primary. diff --git a/src/mongo/db/catalog/rename_collection_test.cpp b/src/mongo/db/catalog/rename_collection_test.cpp index b96dc919b87..79e0e09910b 100644 --- a/src/mongo/db/catalog/rename_collection_test.cpp +++ b/src/mongo/db/catalog/rename_collection_test.cpp @@ -337,7 +337,6 @@ void RenameCollectionTest::setUp() { auto replCoord = std::make_unique<repl::ReplicationCoordinatorMock>(service); _replCoord = replCoord.get(); repl::ReplicationCoordinator::set(service, std::move(replCoord)); - repl::setOplogCollectionName(service); repl::createOplog(_opCtx.get()); // Ensure that we are primary. diff --git a/src/mongo/db/commands/mr_test.cpp b/src/mongo/db/commands/mr_test.cpp index a4ed9383018..8ac437c6eed 100644 --- a/src/mongo/db/commands/mr_test.cpp +++ b/src/mongo/db/commands/mr_test.cpp @@ -414,7 +414,6 @@ void MapReduceCommandTest::setUp() { // Transition to PRIMARY so that the server can accept writes. ASSERT_OK(_getReplCoord()->setFollowerMode(repl::MemberState::RS_PRIMARY)); - repl::setOplogCollectionName(service); repl::createOplog(_opCtx.get()); // Create collection with one document. diff --git a/src/mongo/db/free_mon/free_mon_controller_test.cpp b/src/mongo/db/free_mon/free_mon_controller_test.cpp index a0e9e492ce5..e1b6f7afd81 100644 --- a/src/mongo/db/free_mon/free_mon_controller_test.cpp +++ b/src/mongo/db/free_mon/free_mon_controller_test.cpp @@ -428,7 +428,6 @@ void FreeMonControllerTest::setUp() { // Transition to PRIMARY so that the server can accept writes. ASSERT_OK(_getReplCoord()->setFollowerMode(repl::MemberState::RS_PRIMARY)); - repl::setOplogCollectionName(service); repl::createOplog(_opCtx.get()); // Create collection with one document. diff --git a/src/mongo/db/free_mon/free_mon_storage_test.cpp b/src/mongo/db/free_mon/free_mon_storage_test.cpp index fee8f984d62..1049fcfae7b 100644 --- a/src/mongo/db/free_mon/free_mon_storage_test.cpp +++ b/src/mongo/db/free_mon/free_mon_storage_test.cpp @@ -87,7 +87,6 @@ void FreeMonStorageTest::setUp() { // Transition to PRIMARY so that the server can accept writes. ASSERT_OK(_getReplCoord()->setFollowerMode(repl::MemberState::RS_PRIMARY)); - repl::setOplogCollectionName(service); repl::createOplog(_opCtx.get()); } diff --git a/src/mongo/db/mongod_main.cpp b/src/mongo/db/mongod_main.cpp index ce8b7f477e7..d90aa62c09d 100644 --- a/src/mongo/db/mongod_main.cpp +++ b/src/mongo/db/mongod_main.cpp @@ -998,7 +998,6 @@ void setUpReplication(ServiceContext* serviceContext) { serviceContext, makeReplicaSetNodeExecutor(serviceContext)); repl::ReplicationCoordinator::set(serviceContext, std::move(replCoord)); - repl::setOplogCollectionName(serviceContext); IndexBuildsCoordinator::set(serviceContext, std::make_unique<IndexBuildsCoordinatorMongod>()); diff --git a/src/mongo/db/op_observer_impl_test.cpp b/src/mongo/db/op_observer_impl_test.cpp index f14e713c06a..32828f77705 100644 --- a/src/mongo/db/op_observer_impl_test.cpp +++ b/src/mongo/db/op_observer_impl_test.cpp @@ -75,7 +75,6 @@ public: repl::ReplicationCoordinator::set( service, std::make_unique<repl::ReplicationCoordinatorMock>(service, createReplSettings())); - repl::setOplogCollectionName(service); repl::createOplog(opCtx.get()); // Ensure that we are primary. diff --git a/src/mongo/db/repl/apply_ops_test.cpp b/src/mongo/db/repl/apply_ops_test.cpp index b22e4bf69a3..88b36f5827c 100644 --- a/src/mongo/db/repl/apply_ops_test.cpp +++ b/src/mongo/db/repl/apply_ops_test.cpp @@ -96,7 +96,6 @@ void ApplyOpsTest::setUp() { // Set up ReplicationCoordinator and create oplog. ReplicationCoordinator::set(service, std::make_unique<ReplicationCoordinatorMock>(service)); - setOplogCollectionName(service); createOplog(opCtx.get()); // Ensure that we are primary. diff --git a/src/mongo/db/repl/local_oplog_info.cpp b/src/mongo/db/repl/local_oplog_info.cpp index 881f974aaea..0c4eb1ccc8c 100644 --- a/src/mongo/db/repl/local_oplog_info.cpp +++ b/src/mongo/db/repl/local_oplog_info.cpp @@ -63,14 +63,6 @@ LocalOplogInfo* LocalOplogInfo::get(OperationContext* opCtx) { return get(opCtx->getServiceContext()); } -const NamespaceString& LocalOplogInfo::getOplogCollectionName() const { - return _oplogName; -} - -void LocalOplogInfo::setOplogCollectionName(ServiceContext* service) { - _oplogName = NamespaceString::kRsOplogNamespace; -} - const CollectionPtr& LocalOplogInfo::getCollection() const { return _oplog; } diff --git a/src/mongo/db/repl/local_oplog_info.h b/src/mongo/db/repl/local_oplog_info.h index 880e6bb6b0e..4d96fb0e507 100644 --- a/src/mongo/db/repl/local_oplog_info.h +++ b/src/mongo/db/repl/local_oplog_info.h @@ -56,16 +56,6 @@ public: LocalOplogInfo& operator=(const LocalOplogInfo&) = delete; LocalOplogInfo() = default; - /** - * Returns namespace of the local oplog collection. - */ - const NamespaceString& getOplogCollectionName() const; - - /** - * Detects the current replication mode and sets the "_oplogName" accordingly. - */ - void setOplogCollectionName(ServiceContext* service); - const CollectionPtr& getCollection() const; void setCollection(const CollectionPtr& oplog); void resetCollection(); 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 e6f426933e4..cda26ff534d 100644 --- a/src/mongo/db/repl/mock_repl_coord_server_fixture.cpp +++ b/src/mongo/db/repl/mock_repl_coord_server_fixture.cpp @@ -85,7 +85,6 @@ void MockReplCoordServerFixture::setUp() { ASSERT_TRUE( client.createCollection(NamespaceString::kRsOplogNamespace.ns(), 1024 * 1024, true)); - repl::setOplogCollectionName(service); repl::acquireOplogCollectionForLogging(opCtx()); repl::DropPendingCollectionReaper::set( diff --git a/src/mongo/db/repl/oplog.cpp b/src/mongo/db/repl/oplog.cpp index ddbf101aea1..2b19a51c912 100644 --- a/src/mongo/db/repl/oplog.cpp +++ b/src/mongo/db/repl/oplog.cpp @@ -172,10 +172,6 @@ void registerApplyImportCollectionFn(ApplyImportCollectionFn func) { applyImportCollection = func; } -void setOplogCollectionName(ServiceContext* service) { - LocalOplogInfo::get(service)->setOplogCollectionName(service); -} - void createIndexForApplyOps(OperationContext* opCtx, const BSONObj& indexSpec, const NamespaceString& indexNss, @@ -649,7 +645,7 @@ void createOplog(OperationContext* opCtx, void createOplog(OperationContext* opCtx) { const auto isReplSet = ReplicationCoordinator::get(opCtx)->getReplicationMode() == ReplicationCoordinator::modeReplSet; - createOplog(opCtx, LocalOplogInfo::get(opCtx)->getOplogCollectionName(), isReplSet); + createOplog(opCtx, NamespaceString::kRsOplogNamespace, isReplSet); } std::vector<OplogSlot> getNextOpTimes(OperationContext* opCtx, std::size_t count) { @@ -1790,12 +1786,8 @@ void clearLocalOplogPtr() { } void acquireOplogCollectionForLogging(OperationContext* opCtx) { - auto oplogInfo = LocalOplogInfo::get(opCtx); - const auto& nss = oplogInfo->getOplogCollectionName(); - if (!nss.isEmpty()) { - AutoGetCollection autoColl(opCtx, nss, MODE_IX); - LocalOplogInfo::get(opCtx)->setCollection(autoColl.getCollection()); - } + AutoGetCollection autoColl(opCtx, NamespaceString::kRsOplogNamespace, MODE_IX); + LocalOplogInfo::get(opCtx)->setCollection(autoColl.getCollection()); } void establishOplogCollectionForLogging(OperationContext* opCtx, const CollectionPtr& oplog) { diff --git a/src/mongo/db/repl/oplog.h b/src/mongo/db/repl/oplog.h index 7c8ede8be99..735cf631e14 100644 --- a/src/mongo/db/repl/oplog.h +++ b/src/mongo/db/repl/oplog.h @@ -228,11 +228,6 @@ void initTimestampFromOplog(OperationContext* opCtx, const NamespaceString& oplo void setNewTimestamp(ServiceContext* opCtx, const Timestamp& newTime); /** - * Detects the current replication mode and sets the "_oplogCollectionName" accordingly. - */ -void setOplogCollectionName(ServiceContext* service); - -/** * Signal any waiting AwaitData queries on the oplog that there is new data or metadata available. */ void signalOplogWaiters(); diff --git a/src/mongo/db/repl/oplog_applier_impl_test_fixture.cpp b/src/mongo/db/repl/oplog_applier_impl_test_fixture.cpp index 1948b97e3e7..af2c78725f2 100644 --- a/src/mongo/db/repl/oplog_applier_impl_test_fixture.cpp +++ b/src/mongo/db/repl/oplog_applier_impl_test_fixture.cpp @@ -113,7 +113,6 @@ void OplogApplierImplTest::setUp() { DropPendingCollectionReaper::set( serviceContext, std::make_unique<DropPendingCollectionReaper>(getStorageInterface())); - repl::setOplogCollectionName(serviceContext); repl::createOplog(_opCtx.get()); _consistencyMarkers = std::make_unique<ReplicationConsistencyMarkersMock>(); diff --git a/src/mongo/db/repl/oplog_test.cpp b/src/mongo/db/repl/oplog_test.cpp index 3451e54d592..20edd9e5014 100644 --- a/src/mongo/db/repl/oplog_test.cpp +++ b/src/mongo/db/repl/oplog_test.cpp @@ -70,7 +70,6 @@ void OplogTest::setUp() { // Set up ReplicationCoordinator and create oplog. ReplicationCoordinator::set(service, std::make_unique<ReplicationCoordinatorMock>(service)); - setOplogCollectionName(service); createOplog(opCtx.get()); // Ensure that we are primary. diff --git a/src/mongo/db/repl/primary_only_service_test.cpp b/src/mongo/db/repl/primary_only_service_test.cpp index 9e77afea695..cfd4078de4e 100644 --- a/src/mongo/db/repl/primary_only_service_test.cpp +++ b/src/mongo/db/repl/primary_only_service_test.cpp @@ -298,7 +298,6 @@ public: auto replCoord = std::make_unique<ReplicationCoordinatorMock>(serviceContext); ReplicationCoordinator::set(serviceContext, std::move(replCoord)); - repl::setOplogCollectionName(serviceContext); repl::createOplog(opCtx.get()); // Set up OpObserver so that repl::logOp() will store the oplog entry's optime in // ReplClientInfo. diff --git a/src/mongo/db/repl/replication_recovery_test.cpp b/src/mongo/db/repl/replication_recovery_test.cpp index c8a576ed630..78e78e0d9cb 100644 --- a/src/mongo/db/repl/replication_recovery_test.cpp +++ b/src/mongo/db/repl/replication_recovery_test.cpp @@ -198,7 +198,6 @@ private: ASSERT_OK( ReplicationCoordinator::get(_opCtx.get())->setFollowerMode(MemberState::RS_PRIMARY)); - repl::setOplogCollectionName(service); repl::createOplog(_opCtx.get()); ASSERT_OK(_storageInterface->createCollection( @@ -211,8 +210,6 @@ private: repl::DropPendingCollectionReaper::set( service, std::make_unique<repl::DropPendingCollectionReaper>(_storageInterface)); - - setOplogCollectionName(service); } void tearDown() override { diff --git a/src/mongo/db/repl/rollback_test_fixture.cpp b/src/mongo/db/repl/rollback_test_fixture.cpp index 91a995fc466..be74b09840f 100644 --- a/src/mongo/db/repl/rollback_test_fixture.cpp +++ b/src/mongo/db/repl/rollback_test_fixture.cpp @@ -103,7 +103,6 @@ void RollbackTest::setUp() { _coordinator = new ReplicationCoordinatorRollbackMock(serviceContext); ReplicationCoordinator::set(serviceContext, std::unique_ptr<ReplicationCoordinator>(_coordinator)); - setOplogCollectionName(serviceContext); _opCtx = makeOperationContext(); _replicationProcess->getConsistencyMarkers()->clearAppliedThrough(_opCtx.get(), {}); diff --git a/src/mongo/db/repl/tenant_collection_cloner_test.cpp b/src/mongo/db/repl/tenant_collection_cloner_test.cpp index 59d4fcb803e..dcdd100538b 100644 --- a/src/mongo/db/repl/tenant_collection_cloner_test.cpp +++ b/src/mongo/db/repl/tenant_collection_cloner_test.cpp @@ -126,7 +126,6 @@ protected: ReplicationCoordinator::set( serviceContext, std::make_unique<ReplicationCoordinatorMock>(serviceContext)); - repl::setOplogCollectionName(serviceContext); repl::createOplog(opCtx.get()); // Need real (non-mock) storage for the test. diff --git a/src/mongo/db/repl/tenant_migration_recipient_entry_helpers_test.cpp b/src/mongo/db/repl/tenant_migration_recipient_entry_helpers_test.cpp index cb1cb69d146..824e478af9a 100644 --- a/src/mongo/db/repl/tenant_migration_recipient_entry_helpers_test.cpp +++ b/src/mongo/db/repl/tenant_migration_recipient_entry_helpers_test.cpp @@ -54,7 +54,6 @@ public: std::make_unique<ReplicationCoordinatorMock>(serviceContext)); StorageInterface::set(serviceContext, std::make_unique<StorageInterfaceImpl>()); - repl::setOplogCollectionName(serviceContext); repl::createOplog(opCtx.get()); // Step up the node. @@ -184,4 +183,4 @@ TEST_F(TenantMigrationRecipientEntryHelpersTest, } } // namespace repl -} // namespace mongo
\ No newline at end of file +} // namespace mongo diff --git a/src/mongo/db/repl/tenant_migration_recipient_service_test.cpp b/src/mongo/db/repl/tenant_migration_recipient_service_test.cpp index 11e13075eab..8e681a359e2 100644 --- a/src/mongo/db/repl/tenant_migration_recipient_service_test.cpp +++ b/src/mongo/db/repl/tenant_migration_recipient_service_test.cpp @@ -144,7 +144,6 @@ public: auto replCoord = std::make_unique<ReplicationCoordinatorMock>(serviceContext); ReplicationCoordinator::set(serviceContext, std::move(replCoord)); - repl::setOplogCollectionName(serviceContext); repl::createOplog(opCtx.get()); // Need real (non-mock) storage for the oplog buffer. diff --git a/src/mongo/db/repl/tenant_oplog_applier_test.cpp b/src/mongo/db/repl/tenant_oplog_applier_test.cpp index d995e3b86d6..f1c6e05b0ac 100644 --- a/src/mongo/db/repl/tenant_oplog_applier_test.cpp +++ b/src/mongo/db/repl/tenant_oplog_applier_test.cpp @@ -141,7 +141,6 @@ public: // expected to exist when fetching the next opTime (LocalOplogInfo::getNextOpTimes) to use // for a write. _opCtx = cc().makeOperationContext(); - repl::setOplogCollectionName(service); repl::createOplog(_opCtx.get()); // Ensure that we are primary. diff --git a/src/mongo/db/s/resharding/resharding_recipient_service_test.cpp b/src/mongo/db/s/resharding/resharding_recipient_service_test.cpp index 52dd76a6ad6..debfc34017a 100644 --- a/src/mongo/db/s/resharding/resharding_recipient_service_test.cpp +++ b/src/mongo/db/s/resharding/resharding_recipient_service_test.cpp @@ -74,7 +74,6 @@ public: auto _storageInterfaceImpl = std::make_unique<repl::StorageInterfaceImpl>(); repl::StorageInterface::set(getServiceContext(), std::move(_storageInterfaceImpl)); - repl::setOplogCollectionName(getServiceContext()); repl::createOplog(operationContext()); MongoDSessionCatalog::onStepUp(operationContext()); } diff --git a/src/mongo/db/s/sharding_mongod_test_fixture.cpp b/src/mongo/db/s/sharding_mongod_test_fixture.cpp index d0ccaa291f8..ebb9fae2aa9 100644 --- a/src/mongo/db/s/sharding_mongod_test_fixture.cpp +++ b/src/mongo/db/s/sharding_mongod_test_fixture.cpp @@ -132,7 +132,6 @@ ShardingMongodTestFixture::ShardingMongodTestFixture() { opObserver->addObserver(std::make_unique<ConfigServerOpObserver>()); opObserver->addObserver(std::make_unique<ShardServerOpObserver>()); - repl::setOplogCollectionName(service); repl::createOplog(operationContext()); // Set the highest FCV because otherwise it defaults to the lower FCV. This way we default to diff --git a/src/mongo/db/session_catalog_mongod_test.cpp b/src/mongo/db/session_catalog_mongod_test.cpp index 12adac67cef..e7519fc6f9c 100644 --- a/src/mongo/db/session_catalog_mongod_test.cpp +++ b/src/mongo/db/session_catalog_mongod_test.cpp @@ -49,7 +49,6 @@ protected: ASSERT_OK(replCoord->setFollowerMode(repl::MemberState::RS_PRIMARY)); repl::ReplicationCoordinator::set(service, std::move(replCoord)); - repl::setOplogCollectionName(service); repl::createOplog(_opCtx); service->setFastClockSource(std::make_unique<ClockSourceMock>()); |