diff options
author | Henrik Edin <henrik.edin@mongodb.com> | 2018-09-17 13:35:41 -0400 |
---|---|---|
committer | Henrik Edin <henrik.edin@mongodb.com> | 2018-09-20 10:58:42 -0400 |
commit | c69ec130f14953056461cf40ddf368d8ecf7185b (patch) | |
tree | 70fc2276ec7619c498c833fc8546fc3fd21ba558 /src | |
parent | d5c17e385f543f0afdc4acd5331cc5514549981f (diff) | |
download | mongo-c69ec130f14953056461cf40ddf368d8ecf7185b.tar.gz |
SERVER-36084 Remove sharding runtime dependency from OpObserverImpl
Implement a new subclass of OpObserverImpl to handle the sharding logic.
Can hopefully be a pure subclass of just OpObserver when OpTimes can be passed into observers.
Diffstat (limited to 'src')
22 files changed, 318 insertions, 173 deletions
diff --git a/src/mongo/SConscript b/src/mongo/SConscript index 2021798f780..b59dde57c0d 100644 --- a/src/mongo/SConscript +++ b/src/mongo/SConscript @@ -312,7 +312,6 @@ env.Library( 'db/logical_session_cache_factory_mongod', 'db/mongod_options', 'db/mongodandmongos', - 'db/op_observer_d', 'db/periodic_runner_job_abort_expired_transactions', 'db/periodic_runner_job_decrease_snapshot_cache_pressure', 'db/query_exec', @@ -323,6 +322,7 @@ env.Library( 'db/repl/storage_interface_impl', 'db/repl/topology_coordinator', 'db/s/balancer', + 'db/s/op_observer_sharding_impl', 'db/s/sharding_runtime_d', 'db/serveronly', 'db/service_context_d', diff --git a/src/mongo/db/SConscript b/src/mongo/db/SConscript index ee3f2688ea8..3258448fe23 100644 --- a/src/mongo/db/SConscript +++ b/src/mongo/db/SConscript @@ -132,7 +132,7 @@ env.CppUnitTest( LIBDEPS=[ 'auth/authmocks', 'common', - 'op_observer_d', + 'op_observer_impl', 'repl/oplog_interface_local', 'repl/replmocks', 'service_context_d_test_fixture', @@ -778,7 +778,7 @@ env.Library( ) env.Library( - target="op_observer_d", + target="op_observer_impl", source=[ "op_observer_impl.cpp", ], @@ -786,7 +786,7 @@ env.Library( 'catalog/collection_options', 'op_observer', 'repl/oplog', - 's/sharding_runtime_d', + 's/sharding_api_d', 'views/views_mongod', '$BUILD_DIR/mongo/base', '$BUILD_DIR/mongo/db/catalog/uuid_catalog', @@ -1104,7 +1104,6 @@ env.Library( "index_d", "introspect", "matcher/expressions_mongod_only", - "op_observer_d", "ops/write_ops_parsers", "pipeline/aggregation", "query_exec", @@ -1124,6 +1123,7 @@ env.Library( "repl/topology_coordinator", "rw_concern_d", "s/commands_db_s", + "s/op_observer_sharding_impl", "s/sharding_runtime_d", "startup_warnings_mongod", "stats/counters", diff --git a/src/mongo/db/catalog/SConscript b/src/mongo/db/catalog/SConscript index 8ab0dd4f364..9217087926e 100644 --- a/src/mongo/db/catalog/SConscript +++ b/src/mongo/db/catalog/SConscript @@ -151,11 +151,11 @@ env.CppUnitTest( '$BUILD_DIR/mongo/db/concurrency/lock_manager', '$BUILD_DIR/mongo/db/db_raii', '$BUILD_DIR/mongo/db/namespace_string', - '$BUILD_DIR/mongo/db/op_observer_d', '$BUILD_DIR/mongo/db/repl/drop_pending_collection_reaper', '$BUILD_DIR/mongo/db/repl/optime', '$BUILD_DIR/mongo/db/repl/repl_coordinator_interface', '$BUILD_DIR/mongo/db/repl/replmocks', + '$BUILD_DIR/mongo/db/s/op_observer_sharding_impl', '$BUILD_DIR/mongo/db/service_context_d_test_fixture', ], ) diff --git a/src/mongo/db/catalog/database_test.cpp b/src/mongo/db/catalog/database_test.cpp index 56e2fc14f68..2554b5e3df6 100644 --- a/src/mongo/db/catalog/database_test.cpp +++ b/src/mongo/db/catalog/database_test.cpp @@ -41,7 +41,6 @@ #include "mongo/db/jsobj.h" #include "mongo/db/namespace_string.h" #include "mongo/db/op_observer.h" -#include "mongo/db/op_observer_impl.h" #include "mongo/db/op_observer_registry.h" #include "mongo/db/operation_context.h" #include "mongo/db/repl/drop_pending_collection_reaper.h" @@ -51,6 +50,7 @@ #include "mongo/db/repl/replication_coordinator.h" #include "mongo/db/repl/replication_coordinator_mock.h" #include "mongo/db/repl/storage_interface_mock.h" +#include "mongo/db/s/op_observer_sharding_impl.h" #include "mongo/db/service_context_d_test_fixture.h" #include "mongo/stdx/memory.h" #include "mongo/unittest/unittest.h" @@ -100,7 +100,7 @@ void DatabaseTest::setUp() { // repl::logOp(). repl::logOp() will also store the oplog entry's optime in ReplClientInfo. OpObserverRegistry* opObserverRegistry = dynamic_cast<OpObserverRegistry*>(service->getOpObserver()); - opObserverRegistry->addObserver(stdx::make_unique<OpObserverImpl>()); + opObserverRegistry->addObserver(stdx::make_unique<OpObserverShardingImpl>()); _nss = NamespaceString("test.foo"); } diff --git a/src/mongo/db/db.cpp b/src/mongo/db/db.cpp index 7e531cd2cf7..06ce7d6787b 100644 --- a/src/mongo/db/db.cpp +++ b/src/mongo/db/db.cpp @@ -91,7 +91,6 @@ #include "mongo/db/logical_time_metadata_hook.h" #include "mongo/db/logical_time_validator.h" #include "mongo/db/mongod_options.h" -#include "mongo/db/op_observer_impl.h" #include "mongo/db/op_observer_registry.h" #include "mongo/db/operation_context.h" #include "mongo/db/periodic_runner_job_abort_expired_transactions.h" @@ -112,6 +111,7 @@ #include "mongo/db/s/balancer/balancer.h" #include "mongo/db/s/config/sharding_catalog_manager.h" #include "mongo/db/s/config_server_op_observer.h" +#include "mongo/db/s/op_observer_sharding_impl.h" #include "mongo/db/s/shard_server_op_observer.h" #include "mongo/db/s/sharding_initialization_mongod.h" #include "mongo/db/s/sharding_state_recovery.h" @@ -281,7 +281,7 @@ ExitCode _initAndListen(int listenPort) { serviceContext->setFastClockSource(FastClockSourceFactory::create(Milliseconds(10))); auto opObserverRegistry = stdx::make_unique<OpObserverRegistry>(); - opObserverRegistry->addObserver(stdx::make_unique<OpObserverImpl>()); + opObserverRegistry->addObserver(stdx::make_unique<OpObserverShardingImpl>()); opObserverRegistry->addObserver(stdx::make_unique<UUIDCatalogObserver>()); if (serverGlobalParams.clusterRole == ClusterRole::ShardServer) { diff --git a/src/mongo/db/op_observer_impl.cpp b/src/mongo/db/op_observer_impl.cpp index 99b4034c52f..e4197aad876 100644 --- a/src/mongo/db/op_observer_impl.cpp +++ b/src/mongo/db/op_observer_impl.cpp @@ -48,7 +48,7 @@ #include "mongo/db/repl/oplog.h" #include "mongo/db/repl/oplog_entry_gen.h" #include "mongo/db/repl/replication_coordinator.h" -#include "mongo/db/s/shard_server_op_observer.h" +#include "mongo/db/s/collection_sharding_state.h" #include "mongo/db/server_options.h" #include "mongo/db/session_catalog.h" #include "mongo/db/transaction_participant.h" @@ -63,7 +63,7 @@ namespace { MONGO_FAIL_POINT_DEFINE(failCollectionUpdates); -const auto getDeleteState = OperationContext::declareDecoration<ShardObserverDeleteState>(); +const auto documentKeyDecoration = OperationContext::declareDecoration<BSONObj>(); repl::OpTime logOperation(OperationContext* opCtx, const char* opstr, @@ -273,12 +273,12 @@ OpTimeBundle replLogDelete(OperationContext* opCtx, oplogLink.preImageOpTime = noteOplog; } - auto& deleteState = getDeleteState(opCtx); + auto& documentKey = documentKeyDecoration(opCtx); opTimes.writeOpTime = logOperation(opCtx, "d", nss, uuid, - deleteState.documentKey, + documentKey, nullptr, fromMigrate, opTimes.wallClockTime, @@ -321,6 +321,13 @@ OpTimeBundle replLogApplyOps(OperationContext* opCtx, } // namespace +BSONObj OpObserverImpl::getDocumentKey(OperationContext* opCtx, + NamespaceString const& nss, + BSONObj const& doc) { + auto metadata = CollectionShardingState::get(opCtx, nss)->getMetadata(opCtx); + return metadata->extractDocumentKey(doc).getOwned(); +} + void OpObserverImpl::onCreateIndex(OperationContext* opCtx, const NamespaceString& nss, CollectionUUID uuid, @@ -400,18 +407,12 @@ void OpObserverImpl::onInserts(OperationContext* opCtx, opCtx, nss, session, stmtIdsWritten, lastOpTime, lastWriteDate, boost::none); } - auto* const css = (nss == NamespaceString::kSessionTransactionsTableNamespace || fromMigrate) - ? nullptr - : CollectionShardingRuntime::get(opCtx, nss); - size_t index = 0; for (auto it = first; it != last; it++, index++) { AuthorizationManager::get(opCtx->getServiceContext()) ->logOp(opCtx, "i", nss, it->doc, nullptr); - if (css) { - auto opTime = opTimeList.empty() ? repl::OpTime() : opTimeList[index]; - shardObserveInsertOp(opCtx, css, it->doc, opTime); - } + auto opTime = opTimeList.empty() ? repl::OpTime() : opTimeList[index]; + shardObserveInsertOp(opCtx, nss, it->doc, opTime, fromMigrate); } if (nss.coll() == "system.js") { @@ -476,9 +477,8 @@ void OpObserverImpl::onUpdate(OperationContext* opCtx, const OplogUpdateEntryArg if (args.nss != NamespaceString::kSessionTransactionsTableNamespace) { if (!args.updateArgs.fromMigrate) { - auto* const css = CollectionShardingRuntime::get(opCtx, args.nss); shardObserveUpdateOp(opCtx, - css, + args.nss, args.updateArgs.updatedDoc, opTime.writeOpTime, opTime.prePostImageOpTime); @@ -502,8 +502,9 @@ void OpObserverImpl::onUpdate(OperationContext* opCtx, const OplogUpdateEntryArg void OpObserverImpl::aboutToDelete(OperationContext* opCtx, NamespaceString const& nss, BSONObj const& doc) { - getDeleteState(opCtx) = - ShardObserverDeleteState::make(opCtx, CollectionShardingRuntime::get(opCtx, nss), doc); + documentKeyDecoration(opCtx) = getDocumentKey(opCtx, nss, doc); + + shardObserveAboutToDelete(opCtx, nss, doc); } void OpObserverImpl::onDelete(OperationContext* opCtx, @@ -512,15 +513,16 @@ void OpObserverImpl::onDelete(OperationContext* opCtx, StmtId stmtId, bool fromMigrate, const boost::optional<BSONObj>& deletedDoc) { - auto& deleteState = getDeleteState(opCtx); - invariant(!deleteState.documentKey.isEmpty()); + auto& documentKey = documentKeyDecoration(opCtx); + + invariant(!documentKey.isEmpty()); auto txnParticipant = TransactionParticipant::get(opCtx); const bool inMultiDocumentTransaction = txnParticipant && opCtx->writesAreReplicated() && txnParticipant->inMultiDocumentTransaction(); OpTimeBundle opTime; if (inMultiDocumentTransaction) { - auto operation = OplogEntry::makeDeleteOperation( - nss, uuid, deletedDoc ? deletedDoc.get() : deleteState.documentKey); + auto operation = + OplogEntry::makeDeleteOperation(nss, uuid, deletedDoc ? deletedDoc.get() : documentKey); txnParticipant->addTransactionOperation(opCtx, operation); } else { Session* const session = OperationContextSession::get(opCtx); @@ -535,13 +537,12 @@ void OpObserverImpl::onDelete(OperationContext* opCtx, } AuthorizationManager::get(opCtx->getServiceContext()) - ->logOp(opCtx, "d", nss, deleteState.documentKey, nullptr); + ->logOp(opCtx, "d", nss, documentKey, nullptr); if (nss != NamespaceString::kSessionTransactionsTableNamespace) { if (!fromMigrate) { - auto* const css = CollectionShardingRuntime::get(opCtx, nss); shardObserveDeleteOp( - opCtx, css, deleteState, opTime.writeOpTime, opTime.prePostImageOpTime); + opCtx, nss, documentKey, opTime.writeOpTime, opTime.prePostImageOpTime); } } @@ -550,13 +551,13 @@ void OpObserverImpl::onDelete(OperationContext* opCtx, } else if (nss.coll() == DurableViewCatalog::viewsCollectionName()) { DurableViewCatalog::onExternalChange(opCtx, nss); } else if (nss.isServerConfigurationCollection()) { - auto _id = deleteState.documentKey["_id"]; + auto _id = documentKey["_id"]; if (_id.type() == BSONType::String && _id.String() == FeatureCompatibilityVersionParser::kParameterName) uasserted(40670, "removing FeatureCompatibilityVersion document is not allowed"); } else if (nss == NamespaceString::kSessionTransactionsTableNamespace && !opTime.writeOpTime.isNull()) { - SessionCatalog::get(opCtx)->invalidateSessions(opCtx, deleteState.documentKey); + SessionCatalog::get(opCtx)->invalidateSessions(opCtx, documentKey); } } diff --git a/src/mongo/db/op_observer_impl.h b/src/mongo/db/op_observer_impl.h index 3051cfb63cb..edced9647e5 100644 --- a/src/mongo/db/op_observer_impl.h +++ b/src/mongo/db/op_observer_impl.h @@ -43,78 +43,102 @@ public: const NamespaceString& nss, CollectionUUID uuid, BSONObj indexDoc, - bool fromMigrate) override; + bool fromMigrate) final; void onInserts(OperationContext* opCtx, const NamespaceString& nss, OptionalCollectionUUID uuid, std::vector<InsertStatement>::const_iterator begin, std::vector<InsertStatement>::const_iterator end, - bool fromMigrate) override; - void onUpdate(OperationContext* opCtx, const OplogUpdateEntryArgs& args) override; + bool fromMigrate) final; + void onUpdate(OperationContext* opCtx, const OplogUpdateEntryArgs& args) final; void aboutToDelete(OperationContext* opCtx, const NamespaceString& nss, - const BSONObj& doc) override; + const BSONObj& doc) final; void onDelete(OperationContext* opCtx, const NamespaceString& nss, OptionalCollectionUUID uuid, StmtId stmtId, bool fromMigrate, - const boost::optional<BSONObj>& deletedDoc) override; + const boost::optional<BSONObj>& deletedDoc) final; void onInternalOpMessage(OperationContext* opCtx, const NamespaceString& nss, const boost::optional<UUID> uuid, const BSONObj& msgObj, - const boost::optional<BSONObj> o2MsgObj) override; + const boost::optional<BSONObj> o2MsgObj) final; void onCreateCollection(OperationContext* opCtx, Collection* coll, const NamespaceString& collectionName, const CollectionOptions& options, const BSONObj& idIndex, - const OplogSlot& createOpTime) override; + const OplogSlot& createOpTime) final; void onCollMod(OperationContext* opCtx, const NamespaceString& nss, OptionalCollectionUUID uuid, const BSONObj& collModCmd, const CollectionOptions& oldCollOptions, - boost::optional<TTLCollModInfo> ttlInfo) override; - void onDropDatabase(OperationContext* opCtx, const std::string& dbName) override; + boost::optional<TTLCollModInfo> ttlInfo) final; + void onDropDatabase(OperationContext* opCtx, const std::string& dbName) final; repl::OpTime onDropCollection(OperationContext* opCtx, const NamespaceString& collectionName, - OptionalCollectionUUID uuid) override; + OptionalCollectionUUID uuid) final; void onDropIndex(OperationContext* opCtx, const NamespaceString& nss, OptionalCollectionUUID uuid, const std::string& indexName, - const BSONObj& indexInfo) override; + const BSONObj& indexInfo) final; repl::OpTime preRenameCollection(OperationContext* opCtx, const NamespaceString& fromCollection, const NamespaceString& toCollection, OptionalCollectionUUID uuid, OptionalCollectionUUID dropTargetUUID, - bool stayTemp) override; + bool stayTemp) final; void postRenameCollection(OperationContext* opCtx, const NamespaceString& fromCollection, const NamespaceString& toCollection, OptionalCollectionUUID uuid, OptionalCollectionUUID dropTargetUUID, - bool stayTemp) override; + bool stayTemp) final; void onRenameCollection(OperationContext* opCtx, const NamespaceString& fromCollection, const NamespaceString& toCollection, OptionalCollectionUUID uuid, OptionalCollectionUUID dropTargetUUID, - bool stayTemp) override; + bool stayTemp) final; void onApplyOps(OperationContext* opCtx, const std::string& dbName, - const BSONObj& applyOpCmd) override; + const BSONObj& applyOpCmd) final; void onEmptyCapped(OperationContext* opCtx, const NamespaceString& collectionName, OptionalCollectionUUID uuid); - void onTransactionCommit(OperationContext* opCtx, bool wasPrepared) override; - void onTransactionPrepare(OperationContext* opCtx, const OplogSlot& prepareOpTime) override; - void onTransactionAbort(OperationContext* opCtx) override; - void onReplicationRollback(OperationContext* opCtx, - const RollbackObserverInfo& rbInfo) override; + void onTransactionCommit(OperationContext* opCtx, bool wasPrepared) final; + void onTransactionPrepare(OperationContext* opCtx, const OplogSlot& prepareOpTime) final; + void onTransactionAbort(OperationContext* opCtx) final; + void onReplicationRollback(OperationContext* opCtx, const RollbackObserverInfo& rbInfo) final; + + // Contains the fields of the document that are in the collection's shard key, and "_id". + static BSONObj getDocumentKey(OperationContext* opCtx, + NamespaceString const& nss, + BSONObj const& doc); + +private: + virtual void shardObserveAboutToDelete(OperationContext* opCtx, + NamespaceString const& nss, + BSONObj const& doc) {} + virtual void shardObserveInsertOp(OperationContext* opCtx, + const NamespaceString nss, + const BSONObj& insertedDoc, + const repl::OpTime& opTime, + const bool fromMigrate) {} + virtual void shardObserveUpdateOp(OperationContext* opCtx, + const NamespaceString nss, + const BSONObj& updatedDoc, + const repl::OpTime& opTime, + const repl::OpTime& prePostImageOpTime) {} + virtual void shardObserveDeleteOp(OperationContext* opCtx, + const NamespaceString nss, + const BSONObj& documentKey, + const repl::OpTime& opTime, + const repl::OpTime& preImageOpTime) {} }; } // namespace mongo diff --git a/src/mongo/db/repl/SConscript b/src/mongo/db/repl/SConscript index a82e03769a9..63808bbd362 100644 --- a/src/mongo/db/repl/SConscript +++ b/src/mongo/db/repl/SConscript @@ -99,7 +99,7 @@ env.CppUnitTest( 'replmocks', 'storage_interface_impl', '$BUILD_DIR/mongo/db/auth/authmocks', - '$BUILD_DIR/mongo/db/op_observer_d', + '$BUILD_DIR/mongo/db/s/op_observer_sharding_impl', '$BUILD_DIR/mongo/db/service_context_d_test_fixture', '$BUILD_DIR/mongo/rpc/command_status', ], @@ -713,7 +713,7 @@ env.Library( 'replmocks', 'storage_interface_impl', '$BUILD_DIR/mongo/db/catalog/document_validation', - '$BUILD_DIR/mongo/db/op_observer_d', + '$BUILD_DIR/mongo/db/s/op_observer_sharding_impl', '$BUILD_DIR/mongo/db/service_context_d_test_fixture', ], ) diff --git a/src/mongo/db/repl/do_txn_test.cpp b/src/mongo/db/repl/do_txn_test.cpp index 7a15e2bde71..4fa873600de 100644 --- a/src/mongo/db/repl/do_txn_test.cpp +++ b/src/mongo/db/repl/do_txn_test.cpp @@ -30,7 +30,6 @@ #include "mongo/db/catalog/collection_options.h" #include "mongo/db/catalog/database_holder.h" #include "mongo/db/client.h" -#include "mongo/db/op_observer_impl.h" #include "mongo/db/op_observer_noop.h" #include "mongo/db/op_observer_registry.h" #include "mongo/db/operation_context_session_mongod.h" @@ -39,6 +38,7 @@ #include "mongo/db/repl/repl_client_info.h" #include "mongo/db/repl/replication_coordinator_mock.h" #include "mongo/db/repl/storage_interface_impl.h" +#include "mongo/db/s/op_observer_sharding_impl.h" #include "mongo/db/service_context_d_test_fixture.h" #include "mongo/db/session_catalog.h" #include "mongo/db/transaction_participant.h" @@ -133,7 +133,7 @@ void DoTxnTest::setUp() { // Need the OpObserverImpl in the registry in order for doTxn to work. OpObserverRegistry* opObserverRegistry = dynamic_cast<OpObserverRegistry*>(service->getOpObserver()); - opObserverRegistry->addObserver(stdx::make_unique<OpObserverImpl>()); + opObserverRegistry->addObserver(stdx::make_unique<OpObserverShardingImpl>()); // Use OpObserverMock to track applyOps calls generated by doTxn(). auto opObserver = stdx::make_unique<OpObserverMock>(); diff --git a/src/mongo/db/s/SConscript b/src/mongo/db/s/SConscript index 97826bde3a0..a150e06035f 100644 --- a/src/mongo/db/s/SConscript +++ b/src/mongo/db/s/SConscript @@ -70,6 +70,7 @@ env.Library( '$BUILD_DIR/mongo/db/commands/mongod_fcv', '$BUILD_DIR/mongo/db/db_raii', '$BUILD_DIR/mongo/db/dbhelpers', + '$BUILD_DIR/mongo/db/op_observer_impl', '$BUILD_DIR/mongo/db/ops/write_ops_exec', '$BUILD_DIR/mongo/db/repl/oplog', '$BUILD_DIR/mongo/db/repl/repl_coordinator_interface', @@ -94,6 +95,19 @@ env.Library( ) env.Library( + target='op_observer_sharding_impl', + source=[ + 'op_observer_sharding_impl.cpp', + ], + LIBDEPS=[ + '$BUILD_DIR/mongo/db/op_observer_impl', + ], + LIBDEPS_PRIVATE=[ + 'sharding_runtime_d', + ], +) + +env.Library( target='chunk_splitter', source=[ 'chunk_split_state_driver.cpp', diff --git a/src/mongo/db/s/collection_sharding_state_test.cpp b/src/mongo/db/s/collection_sharding_state_test.cpp index ca60bb77db2..2c2ffcd1080 100644 --- a/src/mongo/db/s/collection_sharding_state_test.cpp +++ b/src/mongo/db/s/collection_sharding_state_test.cpp @@ -29,7 +29,7 @@ #include "mongo/db/catalog_raii.h" #include "mongo/db/s/collection_sharding_runtime.h" -#include "mongo/db/s/shard_server_op_observer.h" +#include "mongo/db/s/op_observer_sharding_impl.h" #include "mongo/db/s/type_shard_identity.h" #include "mongo/s/shard_server_test_fixture.h" @@ -72,11 +72,10 @@ TEST_F(DeleteStateTest, MakeDeleteStateUnsharded) { << true); // Check that an order for deletion from an unsharded collection extracts just the "_id" field - auto deleteState = ShardObserverDeleteState::make(operationContext(), css, doc); - ASSERT_BSONOBJ_EQ(deleteState.documentKey, + ASSERT_BSONOBJ_EQ(OpObserverImpl::getDocumentKey(operationContext(), kTestNss, doc), BSON("_id" << "hello")); - ASSERT_FALSE(deleteState.isMigrating); + ASSERT_FALSE(OpObserverShardingImpl::isMigrating(operationContext(), kTestNss, doc)); } TEST_F(DeleteStateTest, MakeDeleteStateShardedWithoutIdInShardKey) { @@ -97,13 +96,12 @@ TEST_F(DeleteStateTest, MakeDeleteStateShardedWithoutIdInShardKey) { << true); // Verify the shard key is extracted, in correct order, followed by the "_id" field. - auto deleteState = ShardObserverDeleteState::make(operationContext(), css, doc); - ASSERT_BSONOBJ_EQ(deleteState.documentKey, + ASSERT_BSONOBJ_EQ(OpObserverImpl::getDocumentKey(operationContext(), kTestNss, doc), BSON("key" << 100 << "key3" << "abc" << "_id" << "hello")); - ASSERT_FALSE(deleteState.isMigrating); + ASSERT_FALSE(OpObserverShardingImpl::isMigrating(operationContext(), kTestNss, doc)); } TEST_F(DeleteStateTest, MakeDeleteStateShardedWithIdInShardKey) { @@ -123,13 +121,12 @@ TEST_F(DeleteStateTest, MakeDeleteStateShardedWithIdInShardKey) { << 100); // Verify the shard key is extracted with "_id" in the right place. - auto deleteState = ShardObserverDeleteState::make(operationContext(), css, doc); - ASSERT_BSONOBJ_EQ(deleteState.documentKey, + ASSERT_BSONOBJ_EQ(OpObserverImpl::getDocumentKey(operationContext(), kTestNss, doc), BSON("key" << 100 << "_id" << "hello" << "key2" << true)); - ASSERT_FALSE(deleteState.isMigrating); + ASSERT_FALSE(OpObserverShardingImpl::isMigrating(operationContext(), kTestNss, doc)); } TEST_F(DeleteStateTest, MakeDeleteStateShardedWithIdHashInShardKey) { @@ -147,11 +144,10 @@ TEST_F(DeleteStateTest, MakeDeleteStateShardedWithIdHashInShardKey) { << 100); // Verify the shard key is extracted with "_id" in the right place, not hashed. - auto deleteState = ShardObserverDeleteState::make(operationContext(), css, doc); - ASSERT_BSONOBJ_EQ(deleteState.documentKey, + ASSERT_BSONOBJ_EQ(OpObserverImpl::getDocumentKey(operationContext(), kTestNss, doc), BSON("_id" << "hello")); - ASSERT_FALSE(deleteState.isMigrating); + ASSERT_FALSE(OpObserverShardingImpl::isMigrating(operationContext(), kTestNss, doc)); } } // namespace diff --git a/src/mongo/db/s/op_observer_sharding_impl.cpp b/src/mongo/db/s/op_observer_sharding_impl.cpp new file mode 100644 index 00000000000..f6ba177d296 --- /dev/null +++ b/src/mongo/db/s/op_observer_sharding_impl.cpp @@ -0,0 +1,125 @@ +/** + * Copyright (C) 2018 MongoDB Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License, version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * As a special exception, the copyright holders give permission to link the + * code of portions of this program with the OpenSSL library under certain + * conditions as described in each individual source file and distribute + * linked combinations including the program with the OpenSSL library. You + * must comply with the GNU Affero General Public License in all respects + * for all of the code used other than as permitted herein. If you modify + * file(s) with this exception, you may extend this exception to your + * version of the file(s), but you are not obligated to do so. If you do not + * wish to do so, delete this exception statement from your version. If you + * delete this exception statement from all source files in the program, + * then also delete it in the license file. + */ + +#include "mongo/platform/basic.h" + +#include "mongo/db/s/op_observer_sharding_impl.h" + +//#include "mongo/bson/bsonobjbuilder.h" +//#include "mongo/db/auth/authorization_manager.h" +//#include "mongo/db/catalog/collection_catalog_entry.h" +//#include "mongo/db/catalog/collection_options.h" +//#include "mongo/db/catalog/database.h" +//#include "mongo/db/catalog/database_holder.h" +//#include "mongo/db/catalog/namespace_uuid_cache.h" +//#include "mongo/db/commands/feature_compatibility_version.h" +//#include "mongo/db/commands/feature_compatibility_version_parser.h" +//#include "mongo/db/concurrency/d_concurrency.h" +//#include "mongo/db/concurrency/write_conflict_exception.h" +//#include "mongo/db/index/index_descriptor.h" +//#include "mongo/db/logical_time_validator.h" +//#include "mongo/db/namespace_string.h" +//#include "mongo/db/operation_context.h" +//#include "mongo/db/repl/oplog.h" +//#include "mongo/db/repl/oplog_entry_gen.h" +//#include "mongo/db/repl/replication_coordinator.h" +////#include "mongo/db/s/shard_server_op_observer.h" +#include "mongo/db/s/collection_sharding_runtime.h" +#include "mongo/db/s/migration_source_manager.h" +//#include "mongo/db/server_options.h" +//#include "mongo/db/session_catalog.h" +//#include "mongo/db/transaction_participant.h" +//#include "mongo/db/views/durable_view_catalog.h" +//#include "mongo/scripting/engine.h" +//#include "mongo/util/assert_util.h" +//#include "mongo/util/fail_point_service.h" + +namespace mongo { +namespace { +const auto getIsMigrating = OperationContext::declareDecoration<bool>(); +} + +bool OpObserverShardingImpl::isMigrating(OperationContext* opCtx, + NamespaceString const& nss, + BSONObj const& docToDelete) { + auto css = CollectionShardingRuntime::get(opCtx, nss); + auto msm = MigrationSourceManager::get(css); + return msm && msm->getCloner()->isDocumentInMigratingChunk(docToDelete); +} + +void OpObserverShardingImpl::shardObserveAboutToDelete(OperationContext* opCtx, + NamespaceString const& nss, + BSONObj const& docToDelete) { + getIsMigrating(opCtx) = isMigrating(opCtx, nss, docToDelete); +} + +void OpObserverShardingImpl::shardObserveInsertOp(OperationContext* opCtx, + const NamespaceString nss, + const BSONObj& insertedDoc, + const repl::OpTime& opTime, + const bool fromMigrate) { + auto* const css = (nss == NamespaceString::kSessionTransactionsTableNamespace || fromMigrate) + ? nullptr + : CollectionShardingRuntime::get(opCtx, nss); + if (css) { + css->checkShardVersionOrThrow(opCtx); + auto msm = MigrationSourceManager::get(css); + if (msm) { + msm->getCloner()->onInsertOp(opCtx, insertedDoc, opTime); + } + } +} + +void OpObserverShardingImpl::shardObserveUpdateOp(OperationContext* opCtx, + const NamespaceString nss, + const BSONObj& updatedDoc, + const repl::OpTime& opTime, + const repl::OpTime& prePostImageOpTime) { + auto* const css = CollectionShardingRuntime::get(opCtx, nss); + css->checkShardVersionOrThrow(opCtx); + auto msm = MigrationSourceManager::get(css); + if (msm) { + msm->getCloner()->onUpdateOp(opCtx, updatedDoc, opTime, prePostImageOpTime); + } +} + +void OpObserverShardingImpl::shardObserveDeleteOp(OperationContext* opCtx, + const NamespaceString nss, + const BSONObj& documentKey, + const repl::OpTime& opTime, + const repl::OpTime& preImageOpTime) { + auto& isMigrating = getIsMigrating(opCtx); + auto* const css = CollectionShardingRuntime::get(opCtx, nss); + css->checkShardVersionOrThrow(opCtx); + auto msm = MigrationSourceManager::get(css); + if (msm && isMigrating) { + msm->getCloner()->onDeleteOp(opCtx, documentKey, opTime, preImageOpTime); + } +} + +} // namespace mongo diff --git a/src/mongo/db/s/op_observer_sharding_impl.h b/src/mongo/db/s/op_observer_sharding_impl.h new file mode 100644 index 00000000000..7547f542c6f --- /dev/null +++ b/src/mongo/db/s/op_observer_sharding_impl.h @@ -0,0 +1,65 @@ +/** + * Copyright 2016 MongoDB Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License, version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * As a special exception, the copyright holders give permission to link the + * code of portions of this program with the OpenSSL library under certain + * conditions as described in each individual source file and distribute + * linked combinations including the program with the OpenSSL library. You + * must comply with the GNU Affero General Public License in all respects for + * all of the code used other than as permitted herein. If you modify file(s) + * with this exception, you may extend this exception to your version of the + * file(s), but you are not obligated to do so. If you do not wish to do so, + * delete this exception statement from your version. If you delete this + * exception statement from all source files in the program, then also delete + * it in the license file. + */ + +#pragma once + +#include "mongo/db/op_observer_impl.h" + +namespace mongo { + +class OpObserverShardingImpl : public OpObserverImpl { +public: + // True if the document being deleted belongs to a chunk which, while still in the shard, + // is being migrated out. (Not to be confused with "fromMigrate", which tags operations + // that are steps in performing the migration.) + static bool isMigrating(OperationContext* opCtx, + NamespaceString const& nss, + BSONObj const& docToDelete); + +protected: + void shardObserveAboutToDelete(OperationContext* opCtx, + NamespaceString const& nss, + BSONObj const& docToDelete) override; + void shardObserveInsertOp(OperationContext* opCtx, + const NamespaceString nss, + const BSONObj& insertedDoc, + const repl::OpTime& opTime, + const bool fromMigrate) override; + void shardObserveUpdateOp(OperationContext* opCtx, + const NamespaceString nss, + const BSONObj& updatedDoc, + const repl::OpTime& opTime, + const repl::OpTime& prePostImageOpTime) override; + void shardObserveDeleteOp(OperationContext* opCtx, + const NamespaceString nss, + const BSONObj& documentKey, + const repl::OpTime& opTime, + const repl::OpTime& preImageOpTime) override; +}; + +} // namespace mongo diff --git a/src/mongo/db/s/shard_server_op_observer.cpp b/src/mongo/db/s/shard_server_op_observer.cpp index f199098a677..d3fb1491038 100644 --- a/src/mongo/db/s/shard_server_op_observer.cpp +++ b/src/mongo/db/s/shard_server_op_observer.cpp @@ -34,6 +34,7 @@ #include "mongo/bson/util/bson_extract.h" #include "mongo/db/catalog_raii.h" +#include "mongo/db/op_observer_impl.h" #include "mongo/db/s/chunk_split_state_driver.h" #include "mongo/db/s/chunk_splitter.h" #include "mongo/db/s/database_sharding_state.h" @@ -51,7 +52,7 @@ namespace mongo { namespace { -const auto getDeleteState = OperationContext::declareDecoration<ShardObserverDeleteState>(); +const auto getDocumentKey = OperationContext::declareDecoration<BSONObj>(); bool isStandaloneOrPrimary(OperationContext* opCtx) { auto replCoord = repl::ReplicationCoordinator::get(opCtx); @@ -338,8 +339,7 @@ void ShardServerOpObserver::onUpdate(OperationContext* opCtx, const OplogUpdateE void ShardServerOpObserver::aboutToDelete(OperationContext* opCtx, NamespaceString const& nss, BSONObj const& doc) { - auto* const css = CollectionShardingRuntime::get(opCtx, nss); - getDeleteState(opCtx) = ShardObserverDeleteState::make(opCtx, css, doc); + getDocumentKey(opCtx) = OpObserverImpl::getDocumentKey(opCtx, nss, doc); } void ShardServerOpObserver::onDelete(OperationContext* opCtx, @@ -348,10 +348,10 @@ void ShardServerOpObserver::onDelete(OperationContext* opCtx, StmtId stmtId, bool fromMigrate, const boost::optional<BSONObj>& deletedDoc) { - auto& deleteState = getDeleteState(opCtx); + auto& documentKey = getDocumentKey(opCtx); if (nss == NamespaceString::kShardConfigCollectionsNamespace) { - onConfigDeleteInvalidateCachedCollectionMetadataAndNotify(opCtx, deleteState.documentKey); + onConfigDeleteInvalidateCachedCollectionMetadataAndNotify(opCtx, documentKey); } if (nss == NamespaceString::kShardConfigDatabasesNamespace) { if (isStandaloneOrPrimary(opCtx)) { @@ -360,9 +360,9 @@ void ShardServerOpObserver::onDelete(OperationContext* opCtx, // Extract which database entry is being deleted from the _id field. std::string deletedDatabase; - fassert(50772, - bsonExtractStringField( - deleteState.documentKey, ShardDatabaseType::name.name(), &deletedDatabase)); + fassert( + 50772, + bsonExtractStringField(documentKey, ShardDatabaseType::name.name(), &deletedDatabase)); AutoGetDb autoDb(opCtx, deletedDatabase, MODE_X); if (autoDb.getDb()) { @@ -371,7 +371,7 @@ void ShardServerOpObserver::onDelete(OperationContext* opCtx, } if (nss == NamespaceString::kServerConfigurationNamespace) { - if (auto idElem = deleteState.documentKey["_id"]) { + if (auto idElem = documentKey["_id"]) { auto idStr = idElem.str(); if (idStr == ShardIdentityType::IdName) { if (!repl::ReplicationCoordinator::get(opCtx)->getMemberState().rollback()) { @@ -406,48 +406,4 @@ repl::OpTime ShardServerOpObserver::onDropCollection(OperationContext* opCtx, return {}; } -void shardObserveInsertOp(OperationContext* opCtx, - CollectionShardingRuntime* css, - const BSONObj& insertedDoc, - const repl::OpTime& opTime) { - css->checkShardVersionOrThrow(opCtx); - auto msm = MigrationSourceManager::get(css); - if (msm) { - msm->getCloner()->onInsertOp(opCtx, insertedDoc, opTime); - } -} - -void shardObserveUpdateOp(OperationContext* opCtx, - CollectionShardingRuntime* css, - const BSONObj& updatedDoc, - const repl::OpTime& opTime, - const repl::OpTime& prePostImageOpTime) { - css->checkShardVersionOrThrow(opCtx); - auto msm = MigrationSourceManager::get(css); - if (msm) { - msm->getCloner()->onUpdateOp(opCtx, updatedDoc, opTime, prePostImageOpTime); - } -} - -void shardObserveDeleteOp(OperationContext* opCtx, - CollectionShardingRuntime* css, - const ShardObserverDeleteState& deleteState, - const repl::OpTime& opTime, - const repl::OpTime& preImageOpTime) { - css->checkShardVersionOrThrow(opCtx); - auto msm = MigrationSourceManager::get(css); - if (msm && deleteState.isMigrating) { - msm->getCloner()->onDeleteOp(opCtx, deleteState.documentKey, opTime, preImageOpTime); - } -} - -ShardObserverDeleteState ShardObserverDeleteState::make(OperationContext* opCtx, - CollectionShardingRuntime* css, - const BSONObj& docToDelete) { - auto msm = MigrationSourceManager::get(css); - auto metadata = css->getMetadata(opCtx); - return {metadata->extractDocumentKey(docToDelete).getOwned(), - msm && msm->getCloner()->isDocumentInMigratingChunk(docToDelete)}; -} - } // namespace mongo diff --git a/src/mongo/db/s/shard_server_op_observer.h b/src/mongo/db/s/shard_server_op_observer.h index d5737d584e4..dd96a2213af 100644 --- a/src/mongo/db/s/shard_server_op_observer.h +++ b/src/mongo/db/s/shard_server_op_observer.h @@ -141,41 +141,4 @@ public: void onReplicationRollback(OperationContext* opCtx, const RollbackObserverInfo& rbInfo) {} }; - -// Replication oplog OpObserver hooks. Informs the sharding system of changes that may be -// relevant to ongoing operations. -// -// The global lock is expected to be held in mode IX by the caller of any of these functions. - -/** - * Details of documents being removed from a sharded collection. - */ -struct ShardObserverDeleteState { - static ShardObserverDeleteState make(OperationContext* opCtx, - CollectionShardingRuntime* css, - const BSONObj& docToDelete); - // Contains the fields of the document that are in the collection's shard key, and "_id". - BSONObj documentKey; - - // True if the document being deleted belongs to a chunk which, while still in the shard, - // is being migrated out. (Not to be confused with "fromMigrate", which tags operations - // that are steps in performing the migration.) - bool isMigrating; -}; - -void shardObserveInsertOp(OperationContext* opCtx, - CollectionShardingRuntime* css, - const BSONObj& insertedDoc, - const repl::OpTime& opTime); -void shardObserveUpdateOp(OperationContext* opCtx, - CollectionShardingRuntime* css, - const BSONObj& updatedDoc, - const repl::OpTime& opTime, - const repl::OpTime& prePostImageOpTime); -void shardObserveDeleteOp(OperationContext* opCtx, - CollectionShardingRuntime* css, - const ShardObserverDeleteState& deleteState, - const repl::OpTime& opTime, - const repl::OpTime& preImageOpTime); - } // namespace mongo diff --git a/src/mongo/db/s/sharding_initialization_mongod_test.cpp b/src/mongo/db/s/sharding_initialization_mongod_test.cpp index 7748e7492ac..ea2f125475a 100644 --- a/src/mongo/db/s/sharding_initialization_mongod_test.cpp +++ b/src/mongo/db/s/sharding_initialization_mongod_test.cpp @@ -32,10 +32,10 @@ #include "mongo/db/catalog_raii.h" #include "mongo/db/concurrency/d_concurrency.h" #include "mongo/db/dbdirectclient.h" -#include "mongo/db/op_observer_impl.h" #include "mongo/db/op_observer_registry.h" #include "mongo/db/repl/replication_coordinator_mock.h" #include "mongo/db/s/config_server_op_observer.h" +#include "mongo/db/s/op_observer_sharding_impl.h" #include "mongo/db/s/shard_server_catalog_cache_loader.h" #include "mongo/db/s/shard_server_op_observer.h" #include "mongo/db/s/sharding_initialization_mongod.h" @@ -142,7 +142,7 @@ public: serverGlobalParams.clusterRole = ClusterRole::ShardServer; auto makeOpObserver = [&] { auto opObserver = stdx::make_unique<OpObserverRegistry>(); - opObserver->addObserver(stdx::make_unique<OpObserverImpl>()); + opObserver->addObserver(stdx::make_unique<OpObserverShardingImpl>()); opObserver->addObserver(stdx::make_unique<ConfigServerOpObserver>()); opObserver->addObserver(stdx::make_unique<ShardServerOpObserver>()); return opObserver; diff --git a/src/mongo/dbtests/SConscript b/src/mongo/dbtests/SConscript index 77fff17d2d3..8b5eb78c851 100644 --- a/src/mongo/dbtests/SConscript +++ b/src/mongo/dbtests/SConscript @@ -119,7 +119,6 @@ dbtest = env.Program( "$BUILD_DIR/mongo/db/concurrency/deferred_writer", "$BUILD_DIR/mongo/db/logical_clock", "$BUILD_DIR/mongo/db/logical_time_metadata_hook", - "$BUILD_DIR/mongo/db/op_observer_d", "$BUILD_DIR/mongo/db/pipeline/document_value_test_util", "$BUILD_DIR/mongo/db/query/collation/collator_interface_mock", "$BUILD_DIR/mongo/db/query_exec", @@ -132,6 +131,7 @@ dbtest = env.Program( "$BUILD_DIR/mongo/db/repl/replmocks", "$BUILD_DIR/mongo/db/repl/serveronly_repl", "$BUILD_DIR/mongo/db/repl/storage_interface_impl", + "$BUILD_DIR/mongo/db/s/op_observer_sharding_impl", "$BUILD_DIR/mongo/db/serveronly", "$BUILD_DIR/mongo/db/sessions_collection_standalone", "$BUILD_DIR/mongo/db/storage/kv/kv_engine_core", diff --git a/src/mongo/dbtests/repltests.cpp b/src/mongo/dbtests/repltests.cpp index 662f6c8430e..a2d6e66b2c7 100644 --- a/src/mongo/dbtests/repltests.cpp +++ b/src/mongo/dbtests/repltests.cpp @@ -43,13 +43,13 @@ #include "mongo/db/db_raii.h" #include "mongo/db/dbdirectclient.h" #include "mongo/db/json.h" -#include "mongo/db/op_observer_impl.h" #include "mongo/db/ops/update.h" #include "mongo/db/repl/oplog.h" #include "mongo/db/repl/repl_client_info.h" #include "mongo/db/repl/replication_coordinator.h" #include "mongo/db/repl/replication_coordinator_mock.h" #include "mongo/db/repl/sync_tail.h" +#include "mongo/db/s/op_observer_sharding_impl.h" #include "mongo/dbtests/dbtests.h" #include "mongo/transport/transport_layer_asio.h" #include "mongo/util/log.h" @@ -133,7 +133,7 @@ public: // to avoid the invariant in ReplClientInfo::setLastOp that the optime only goes forward. repl::ReplClientInfo::forClient(_opCtx.getClient()).clearLastOp_forTest(); - getGlobalServiceContext()->setOpObserver(stdx::make_unique<OpObserverImpl>()); + getGlobalServiceContext()->setOpObserver(stdx::make_unique<OpObserverShardingImpl>()); setOplogCollectionName(getGlobalServiceContext()); createOplog(&_opCtx); diff --git a/src/mongo/dbtests/storage_timestamp_tests.cpp b/src/mongo/dbtests/storage_timestamp_tests.cpp index 115eaa10d51..89ca7ec6c83 100644 --- a/src/mongo/dbtests/storage_timestamp_tests.cpp +++ b/src/mongo/dbtests/storage_timestamp_tests.cpp @@ -49,7 +49,6 @@ #include "mongo/db/index/index_descriptor.h" #include "mongo/db/logical_clock.h" #include "mongo/db/multi_key_path_tracker.h" -#include "mongo/db/op_observer_impl.h" #include "mongo/db/op_observer_registry.h" #include "mongo/db/operation_context_session_mongod.h" #include "mongo/db/repl/apply_ops.h" @@ -70,6 +69,7 @@ #include "mongo/db/repl/storage_interface_impl.h" #include "mongo/db/repl/sync_tail.h" #include "mongo/db/repl/timestamp_block.h" +#include "mongo/db/s/op_observer_sharding_impl.h" #include "mongo/db/service_context.h" #include "mongo/db/session.h" #include "mongo/db/storage/kv/kv_storage_engine.h" @@ -173,7 +173,7 @@ public: auto registry = stdx::make_unique<OpObserverRegistry>(); registry->addObserver(stdx::make_unique<UUIDCatalogObserver>()); - registry->addObserver(stdx::make_unique<OpObserverImpl>()); + registry->addObserver(stdx::make_unique<OpObserverShardingImpl>()); _opCtx->getServiceContext()->setOpObserver(std::move(registry)); repl::setOplogCollectionName(getGlobalServiceContext()); diff --git a/src/mongo/embedded/SConscript b/src/mongo/embedded/SConscript index ece5e89334d..93265a976cd 100644 --- a/src/mongo/embedded/SConscript +++ b/src/mongo/embedded/SConscript @@ -51,7 +51,7 @@ env.Library( '$BUILD_DIR/mongo/db/concurrency/lock_manager', '$BUILD_DIR/mongo/db/logical_session_cache', '$BUILD_DIR/mongo/db/logical_session_cache_impl', - '$BUILD_DIR/mongo/db/op_observer_d', + '$BUILD_DIR/mongo/db/op_observer_impl', '$BUILD_DIR/mongo/db/repair_database_and_check_version', '$BUILD_DIR/mongo/db/repl/repl_coordinator_interface', '$BUILD_DIR/mongo/db/repl/replica_set_messages', diff --git a/src/mongo/s/SConscript b/src/mongo/s/SConscript index 1dbc4f3d9a0..c1bb1baa369 100644 --- a/src/mongo/s/SConscript +++ b/src/mongo/s/SConscript @@ -203,9 +203,10 @@ env.Library( 'sharding_mongod_test_fixture.cpp', ], LIBDEPS=[ - '$BUILD_DIR/mongo/db/op_observer_d', '$BUILD_DIR/mongo/db/repl/drop_pending_collection_reaper', '$BUILD_DIR/mongo/db/repl/replmocks', + '$BUILD_DIR/mongo/db/s/op_observer_sharding_impl', + '$BUILD_DIR/mongo/db/s/sharding_runtime_d', '$BUILD_DIR/mongo/db/service_context_d_test_fixture', 'sharding_test_fixture_common', ], diff --git a/src/mongo/s/sharding_mongod_test_fixture.cpp b/src/mongo/s/sharding_mongod_test_fixture.cpp index a91670bf753..ee47ab1ab1c 100644 --- a/src/mongo/s/sharding_mongod_test_fixture.cpp +++ b/src/mongo/s/sharding_mongod_test_fixture.cpp @@ -42,7 +42,6 @@ #include "mongo/db/client.h" #include "mongo/db/commands.h" #include "mongo/db/namespace_string.h" -#include "mongo/db/op_observer_impl.h" #include "mongo/db/op_observer_registry.h" #include "mongo/db/query/cursor_response.h" #include "mongo/db/query/query_request.h" @@ -55,6 +54,7 @@ #include "mongo/db/repl/replication_recovery_mock.h" #include "mongo/db/repl/storage_interface_mock.h" #include "mongo/db/s/config_server_op_observer.h" +#include "mongo/db/s/op_observer_sharding_impl.h" #include "mongo/db/s/shard_server_op_observer.h" #include "mongo/executor/network_interface_mock.h" #include "mongo/executor/task_executor_pool.h" @@ -136,7 +136,7 @@ void ShardingMongodTestFixture::setUp() { repl::StorageInterface::set(service, std::move(storagePtr)); auto opObserver = checked_cast<OpObserverRegistry*>(service->getOpObserver()); - opObserver->addObserver(stdx::make_unique<OpObserverImpl>()); + opObserver->addObserver(stdx::make_unique<OpObserverShardingImpl>()); opObserver->addObserver(stdx::make_unique<ConfigServerOpObserver>()); opObserver->addObserver(stdx::make_unique<ShardServerOpObserver>()); |