summaryrefslogtreecommitdiff
path: root/src/mongo/db/s
diff options
context:
space:
mode:
authorKaloian Manassiev <kaloian.manassiev@mongodb.com>2017-12-14 11:57:35 -0500
committerKaloian Manassiev <kaloian.manassiev@mongodb.com>2017-12-16 11:43:28 -0500
commit8467708af7fa83f8827362b80f56dab4aad30a41 (patch)
treeab7858f01ec8ced3111c583ec33e1a55f89d27fe /src/mongo/db/s
parent6cbca62471218a08a4fdf8785bd1e1e38cf9bde3 (diff)
downloadmongo-8467708af7fa83f8827362b80f56dab4aad30a41.tar.gz
SERVER-29909 Remove circular dependency between db_raii and sharding libraries
Diffstat (limited to 'src/mongo/db/s')
-rw-r--r--src/mongo/db/s/SConscript34
-rw-r--r--src/mongo/db/s/active_migrations_registry.cpp2
-rw-r--r--src/mongo/db/s/check_sharding_index_command.cpp2
-rw-r--r--src/mongo/db/s/cleanup_orphaned_cmd.cpp5
-rw-r--r--src/mongo/db/s/collection_range_deleter.cpp5
-rw-r--r--src/mongo/db/s/collection_range_deleter_test.cpp8
-rw-r--r--src/mongo/db/s/collection_sharding_state.cpp6
-rw-r--r--src/mongo/db/s/collection_sharding_state_test.cpp101
-rw-r--r--src/mongo/db/s/flush_routing_table_cache_updates_command.cpp2
-rw-r--r--src/mongo/db/s/get_shard_version_command.cpp3
-rw-r--r--src/mongo/db/s/merge_chunks_command.cpp4
-rw-r--r--src/mongo/db/s/metadata_manager.cpp2
-rw-r--r--src/mongo/db/s/metadata_manager_test.cpp4
-rw-r--r--src/mongo/db/s/migration_chunk_cloner_source_legacy.cpp3
-rw-r--r--src/mongo/db/s/migration_chunk_cloner_source_legacy_commands.cpp2
-rw-r--r--src/mongo/db/s/migration_chunk_cloner_source_legacy_test.cpp3
-rw-r--r--src/mongo/db/s/migration_destination_manager.cpp11
-rw-r--r--src/mongo/db/s/migration_source_manager.cpp2
-rw-r--r--src/mongo/db/s/move_chunk_command.cpp15
-rw-r--r--src/mongo/db/s/session_catalog_migration_source.cpp3
-rw-r--r--src/mongo/db/s/set_shard_version_command.cpp6
-rw-r--r--src/mongo/db/s/sharding_state.cpp12
-rw-r--r--src/mongo/db/s/sharding_state_recovery.cpp2
-rw-r--r--src/mongo/db/s/split_chunk.cpp2
-rw-r--r--src/mongo/db/s/split_vector.cpp2
25 files changed, 112 insertions, 129 deletions
diff --git a/src/mongo/db/s/SConscript b/src/mongo/db/s/SConscript
index b05686b906e..1dd799cfe39 100644
--- a/src/mongo/db/s/SConscript
+++ b/src/mongo/db/s/SConscript
@@ -90,12 +90,10 @@ env.Library(
LIBDEPS=[
'$BUILD_DIR/mongo/base',
'$BUILD_DIR/mongo/bson/util/bson_extract',
- '$BUILD_DIR/mongo/db/catalog/collection',
- '$BUILD_DIR/mongo/db/catalog/database',
+ '$BUILD_DIR/mongo/db/catalog/catalog_raii',
'$BUILD_DIR/mongo/db/catalog/index_catalog',
'$BUILD_DIR/mongo/db/catalog/index_create',
'$BUILD_DIR/mongo/db/common',
- '$BUILD_DIR/mongo/db/concurrency/lock_manager',
'$BUILD_DIR/mongo/db/query/internal_plans',
'$BUILD_DIR/mongo/s/client/shard_local',
'$BUILD_DIR/mongo/s/coreshard',
@@ -106,8 +104,6 @@ env.Library(
'migration_types',
'sharding_task_executor',
'type_shard_identity',
- #'$BUILD_DIR/mongo/db/catalog/catalog', # CYCLE
- #'$BUILD_DIR/mongo/db/db_raii', # CYCLE
#'$BUILD_DIR/mongo/db/dbhelpers', # CYCLE
#'$BUILD_DIR/mongo/db/write_ops', # CYCLE
#'$BUILD_DIR/mongo/db/query/query', # CYCLE
@@ -286,37 +282,37 @@ env.Library(
'split_chunk.cpp',
],
LIBDEPS=[
- 'sharding',
'$BUILD_DIR/mongo/base',
'$BUILD_DIR/mongo/bson/util/bson_extract',
+ '$BUILD_DIR/mongo/db/catalog/catalog_raii',
'$BUILD_DIR/mongo/db/clientcursor',
- '$BUILD_DIR/mongo/db/db_raii',
'$BUILD_DIR/mongo/db/dbhelpers',
'$BUILD_DIR/mongo/db/exec/exec',
'$BUILD_DIR/mongo/db/pipeline/serveronly',
'$BUILD_DIR/mongo/db/query/query',
'$BUILD_DIR/mongo/db/rw_concern_d',
'$BUILD_DIR/mongo/s/catalog/sharding_catalog_manager',
+ 'sharding',
]
)
env.Library(
target='split_vector',
source=[
- 'split_vector.cpp',
+ 'split_vector.cpp',
],
LIBDEPS=[
- '$BUILD_DIR/mongo/db/bson/dotted_path_support',
- '$BUILD_DIR/mongo/db/commands/dcommands_fcv',
- '$BUILD_DIR/mongo/db/commands/server_status',
- '$BUILD_DIR/mongo/db/db_raii',
- '$BUILD_DIR/mongo/db/dbhelpers',
- '$BUILD_DIR/mongo/db/index_d',
- '$BUILD_DIR/mongo/db/repl/repl_coordinator_global',
- '$BUILD_DIR/mongo/s/sharding_request_types',
- 'balancer',
- 'collection_metadata',
- 'sharding',
+ '$BUILD_DIR/mongo/db/bson/dotted_path_support',
+ '$BUILD_DIR/mongo/db/catalog/catalog_raii',
+ '$BUILD_DIR/mongo/db/commands/dcommands_fcv',
+ '$BUILD_DIR/mongo/db/commands/server_status',
+ '$BUILD_DIR/mongo/db/dbhelpers',
+ '$BUILD_DIR/mongo/db/index_d',
+ '$BUILD_DIR/mongo/db/repl/repl_coordinator_global',
+ '$BUILD_DIR/mongo/s/sharding_request_types',
+ 'balancer',
+ 'collection_metadata',
+ 'sharding',
]
)
diff --git a/src/mongo/db/s/active_migrations_registry.cpp b/src/mongo/db/s/active_migrations_registry.cpp
index 91aa5dd7bf4..9aadaeb1937 100644
--- a/src/mongo/db/s/active_migrations_registry.cpp
+++ b/src/mongo/db/s/active_migrations_registry.cpp
@@ -31,7 +31,7 @@
#include "mongo/db/s/active_migrations_registry.h"
#include "mongo/base/status_with.h"
-#include "mongo/db/db_raii.h"
+#include "mongo/db/catalog/catalog_raii.h"
#include "mongo/db/s/collection_sharding_state.h"
#include "mongo/db/s/migration_session_id.h"
#include "mongo/db/s/migration_source_manager.h"
diff --git a/src/mongo/db/s/check_sharding_index_command.cpp b/src/mongo/db/s/check_sharding_index_command.cpp
index 7fc5eb0c6ab..6955d93db83 100644
--- a/src/mongo/db/s/check_sharding_index_command.cpp
+++ b/src/mongo/db/s/check_sharding_index_command.cpp
@@ -35,9 +35,9 @@
#include "mongo/db/auth/authorization_session.h"
#include "mongo/db/auth/privilege.h"
#include "mongo/db/bson/dotted_path_support.h"
+#include "mongo/db/catalog/catalog_raii.h"
#include "mongo/db/catalog/index_catalog.h"
#include "mongo/db/commands.h"
-#include "mongo/db/db_raii.h"
#include "mongo/db/dbhelpers.h"
#include "mongo/db/exec/working_set_common.h"
#include "mongo/db/index/index_descriptor.h"
diff --git a/src/mongo/db/s/cleanup_orphaned_cmd.cpp b/src/mongo/db/s/cleanup_orphaned_cmd.cpp
index 69e7b311b79..99a8ee8fc10 100644
--- a/src/mongo/db/s/cleanup_orphaned_cmd.cpp
+++ b/src/mongo/db/s/cleanup_orphaned_cmd.cpp
@@ -32,21 +32,18 @@
#include <boost/optional.hpp>
#include <string>
-#include <vector>
#include "mongo/db/auth/action_type.h"
#include "mongo/db/auth/authorization_manager.h"
#include "mongo/db/auth/authorization_session.h"
#include "mongo/db/auth/privilege.h"
+#include "mongo/db/catalog/catalog_raii.h"
#include "mongo/db/commands.h"
-#include "mongo/db/db_raii.h"
#include "mongo/db/field_parser.h"
#include "mongo/db/jsobj.h"
#include "mongo/db/namespace_string.h"
#include "mongo/db/range_arithmetic.h"
-#include "mongo/db/repl/replication_coordinator_global.h"
#include "mongo/db/s/chunk_move_write_concern_options.h"
-#include "mongo/db/s/collection_metadata.h"
#include "mongo/db/s/collection_sharding_state.h"
#include "mongo/db/s/sharding_state.h"
#include "mongo/db/service_context.h"
diff --git a/src/mongo/db/s/collection_range_deleter.cpp b/src/mongo/db/s/collection_range_deleter.cpp
index 7bf41703968..050013c6c65 100644
--- a/src/mongo/db/s/collection_range_deleter.cpp
+++ b/src/mongo/db/s/collection_range_deleter.cpp
@@ -35,11 +35,10 @@
#include <algorithm>
#include <utility>
-#include "mongo/db/catalog/collection.h"
+#include "mongo/db/catalog/catalog_raii.h"
#include "mongo/db/catalog/index_catalog.h"
#include "mongo/db/client.h"
#include "mongo/db/concurrency/write_conflict_exception.h"
-#include "mongo/db/db_raii.h"
#include "mongo/db/dbhelpers.h"
#include "mongo/db/exec/working_set_common.h"
#include "mongo/db/index/index_descriptor.h"
@@ -49,9 +48,7 @@
#include "mongo/db/query/query_knobs.h"
#include "mongo/db/query/query_planner.h"
#include "mongo/db/repl/repl_client_info.h"
-#include "mongo/db/repl/replication_coordinator_global.h"
#include "mongo/db/s/collection_sharding_state.h"
-#include "mongo/db/s/metadata_manager.h"
#include "mongo/db/s/sharding_state.h"
#include "mongo/db/service_context.h"
#include "mongo/db/write_concern.h"
diff --git a/src/mongo/db/s/collection_range_deleter_test.cpp b/src/mongo/db/s/collection_range_deleter_test.cpp
index 8939860c9be..1b6bb61928f 100644
--- a/src/mongo/db/s/collection_range_deleter_test.cpp
+++ b/src/mongo/db/s/collection_range_deleter_test.cpp
@@ -32,17 +32,14 @@
#include "mongo/bson/bsonobjbuilder.h"
#include "mongo/client/query.h"
#include "mongo/client/remote_command_targeter_mock.h"
+#include "mongo/db/catalog/catalog_raii.h"
#include "mongo/db/client.h"
-#include "mongo/db/db_raii.h"
#include "mongo/db/dbdirectclient.h"
#include "mongo/db/index/index_descriptor.h"
#include "mongo/db/keypattern.h"
-#include "mongo/db/repl/replication_coordinator_global.h"
#include "mongo/db/repl/replication_coordinator_mock.h"
-#include "mongo/db/s/collection_range_deleter.h"
#include "mongo/db/s/collection_sharding_state.h"
#include "mongo/db/s/sharding_state.h"
-#include "mongo/db/service_context_d_test_fixture.h"
#include "mongo/s/balancer_configuration.h"
#include "mongo/s/chunk_version.h"
#include "mongo/s/client/shard_registry.h"
@@ -70,8 +67,7 @@ protected:
serverGlobalParams.clusterRole = ClusterRole::ShardServer;
ShardingMongodTestFixture::setUp();
replicationCoordinator()->alwaysAllowWrites(true);
- initializeGlobalShardingStateForMongodForTest(ConnectionString(dummyHost))
- .transitional_ignore();
+ ASSERT_OK(initializeGlobalShardingStateForMongodForTest(ConnectionString(dummyHost)));
// RemoteCommandTargeterMock::get(shardRegistry()->getConfigShard()->getTargeter())
// ->setConnectionStringReturnValue(kConfigConnStr);
diff --git a/src/mongo/db/s/collection_sharding_state.cpp b/src/mongo/db/s/collection_sharding_state.cpp
index 872f8fbc11a..2458d9861c5 100644
--- a/src/mongo/db/s/collection_sharding_state.cpp
+++ b/src/mongo/db/s/collection_sharding_state.cpp
@@ -33,12 +33,10 @@
#include "mongo/db/s/collection_sharding_state.h"
#include "mongo/bson/util/bson_extract.h"
+#include "mongo/db/catalog/catalog_raii.h"
#include "mongo/db/client.h"
-#include "mongo/db/concurrency/lock_state.h"
-#include "mongo/db/db_raii.h"
#include "mongo/db/operation_context.h"
-#include "mongo/db/repl/replication_coordinator_global.h"
-#include "mongo/db/s/collection_metadata.h"
+#include "mongo/db/repl/replication_coordinator.h"
#include "mongo/db/s/migration_chunk_cloner_source.h"
#include "mongo/db/s/migration_source_manager.h"
#include "mongo/db/s/operation_sharding_state.h"
diff --git a/src/mongo/db/s/collection_sharding_state_test.cpp b/src/mongo/db/s/collection_sharding_state_test.cpp
index f9fcbc69420..3f64a1be7d2 100644
--- a/src/mongo/db/s/collection_sharding_state_test.cpp
+++ b/src/mongo/db/s/collection_sharding_state_test.cpp
@@ -27,12 +27,9 @@
#include "mongo/platform/basic.h"
-#include "mongo/db/s/collection_sharding_state.h"
-
-#include "mongo/db/concurrency/d_concurrency.h"
-#include "mongo/db/db_raii.h"
+#include "mongo/db/catalog/catalog_raii.h"
#include "mongo/db/namespace_string.h"
-#include "mongo/db/s/collection_metadata.h"
+#include "mongo/db/s/collection_sharding_state.h"
#include "mongo/db/s/sharding_state.h"
#include "mongo/db/s/type_shard_identity.h"
#include "mongo/s/shard_server_test_fixture.h"
@@ -40,6 +37,8 @@
namespace mongo {
namespace {
+const NamespaceString kTestNss("TestDB", "TestColl");
+
class CollShardingStateTest : public ShardServerTestFixture {
public:
void setUp() override {
@@ -165,10 +164,6 @@ TEST_F(CollShardingStateTest, GlobalInitDoesntGetsCalledIfShardIdentityDocWasNot
ASSERT_EQ(0, getInitCallCount());
}
-namespace {
-
-NamespaceString testNss("testDB", "TestColl");
-
/**
* Constructs a CollectionMetadata suitable for refreshing a CollectionShardingState. The only
* salient detail is the argument `keyPattern` which, defining the shard key, selects the fields
@@ -178,78 +173,108 @@ NamespaceString testNss("testDB", "TestColl");
auto makeAMetadata(BSONObj const& keyPattern) -> std::unique_ptr<CollectionMetadata> {
const OID epoch = OID::gen();
auto range = ChunkRange(BSON("key" << MINKEY), BSON("key" << MAXKEY));
- auto chunk = ChunkType(testNss, std::move(range), ChunkVersion(1, 0, epoch), ShardId("other"));
+ auto chunk = ChunkType(kTestNss, std::move(range), ChunkVersion(1, 0, epoch), ShardId("other"));
auto cm = ChunkManager::makeNew(
- testNss, UUID::gen(), KeyPattern(keyPattern), nullptr, false, epoch, {std::move(chunk)});
+ kTestNss, UUID::gen(), KeyPattern(keyPattern), nullptr, false, epoch, {std::move(chunk)});
return stdx::make_unique<CollectionMetadata>(std::move(cm), ShardId("this"));
}
-} // namespace
-
-// clang-format off
-
TEST_F(CollShardingStateTest, MakeDeleteStateUnsharded) {
- AutoGetCollection autoColl(operationContext(), testNss, MODE_IX);
- auto* css = CollectionShardingState::get(operationContext(), testNss);
-
- auto doc = BSON("key3" << "abc" << "key" << 3 << "_id" << "hello" << "key2" << true);
+ AutoGetCollection autoColl(operationContext(), kTestNss, MODE_IX);
+ auto* css = CollectionShardingState::get(operationContext(), kTestNss);
+
+ auto doc = BSON("key3"
+ << "abc"
+ << "key"
+ << 3
+ << "_id"
+ << "hello"
+ << "key2"
+ << true);
// First, check that an order for deletion from an unsharded collection (where css has not been
// "refreshed" with chunk metadata) extracts just the "_id" field:
auto deleteState = css->makeDeleteState(doc);
- ASSERT_BSONOBJ_EQ(deleteState.documentKey, BSON("_id" << "hello"));
+ ASSERT_BSONOBJ_EQ(deleteState.documentKey,
+ BSON("_id"
+ << "hello"));
ASSERT_FALSE(deleteState.isMigrating);
}
TEST_F(CollShardingStateTest, MakeDeleteStateShardedWithoutIdInShardKey) {
- AutoGetCollection autoColl(operationContext(), testNss, MODE_IX);
- auto* css = CollectionShardingState::get(operationContext(), testNss);
+ AutoGetCollection autoColl(operationContext(), kTestNss, MODE_IX);
+ auto* css = CollectionShardingState::get(operationContext(), kTestNss);
// Push a CollectionMetadata with a shard key not including "_id"...
css->refreshMetadata(operationContext(), makeAMetadata(BSON("key" << 1 << "key3" << 1)));
// The order of fields in `doc` deliberately does not match the shard key
- auto doc = BSON("key3" << "abc" << "key" << 100 << "_id" << "hello" << "key2" << true);
+ auto doc = BSON("key3"
+ << "abc"
+ << "key"
+ << 100
+ << "_id"
+ << "hello"
+ << "key2"
+ << true);
// Verify the shard key is extracted, in correct order, followed by the "_id" field.
auto deleteState = css->makeDeleteState(doc);
- ASSERT_BSONOBJ_EQ(
- deleteState.documentKey, BSON("key" << 100 << "key3" << "abc" << "_id" << "hello"));
+ ASSERT_BSONOBJ_EQ(deleteState.documentKey,
+ BSON("key" << 100 << "key3"
+ << "abc"
+ << "_id"
+ << "hello"));
ASSERT_FALSE(deleteState.isMigrating);
}
TEST_F(CollShardingStateTest, MakeDeleteStateShardedWithIdInShardKey) {
- AutoGetCollection autoColl(operationContext(), testNss, MODE_IX);
- auto* css = CollectionShardingState::get(operationContext(), testNss);
+ AutoGetCollection autoColl(operationContext(), kTestNss, MODE_IX);
+ auto* css = CollectionShardingState::get(operationContext(), kTestNss);
// Push a CollectionMetadata with a shard key that does have "_id" in the middle...
- css->refreshMetadata(
- operationContext(), makeAMetadata(BSON("key" << 1 << "_id" << 1 << "key2" << 1)));
+ css->refreshMetadata(operationContext(),
+ makeAMetadata(BSON("key" << 1 << "_id" << 1 << "key2" << 1)));
// The order of fields in `doc` deliberately does not match the shard key
- auto doc = BSON("key2" << true << "key3" << "abc" << "_id" << "hello" << "key" << 100);
+ auto doc = BSON("key2" << true << "key3"
+ << "abc"
+ << "_id"
+ << "hello"
+ << "key"
+ << 100);
// Verify the shard key is extracted with "_id" in the right place.
auto deleteState = css->makeDeleteState(doc);
- ASSERT_BSONOBJ_EQ(
- deleteState.documentKey, BSON("key" << 100 << "_id" << "hello" << "key2" << true));
+ ASSERT_BSONOBJ_EQ(deleteState.documentKey,
+ BSON("key" << 100 << "_id"
+ << "hello"
+ << "key2"
+ << true));
ASSERT_FALSE(deleteState.isMigrating);
}
TEST_F(CollShardingStateTest, MakeDeleteStateShardedWithIdHashInShardKey) {
- AutoGetCollection autoColl(operationContext(), testNss, MODE_IX);
- auto* css = CollectionShardingState::get(operationContext(), testNss);
+ AutoGetCollection autoColl(operationContext(), kTestNss, MODE_IX);
+ auto* css = CollectionShardingState::get(operationContext(), kTestNss);
// Push a CollectionMetadata with a shard key "_id", hashed.
- auto aMetadata = makeAMetadata(BSON("_id" << "hashed"));
+ auto aMetadata = makeAMetadata(BSON("_id"
+ << "hashed"));
css->refreshMetadata(operationContext(), std::move(aMetadata));
- auto doc = BSON("key2" << true << "_id" << "hello" << "key" << 100);
+ auto doc = BSON("key2" << true << "_id"
+ << "hello"
+ << "key"
+ << 100);
// Verify the shard key is extracted with "_id" in the right place, not hashed.
auto deleteState = css->makeDeleteState(doc);
- ASSERT_BSONOBJ_EQ(deleteState.documentKey, BSON("_id" << "hello"));
+ ASSERT_BSONOBJ_EQ(deleteState.documentKey,
+ BSON("_id"
+ << "hello"));
ASSERT_FALSE(deleteState.isMigrating);
}
-} // unnamed namespace
+
+} // namespace
} // namespace mongo
diff --git a/src/mongo/db/s/flush_routing_table_cache_updates_command.cpp b/src/mongo/db/s/flush_routing_table_cache_updates_command.cpp
index 70a7ac8c4e8..3bdf4d5556f 100644
--- a/src/mongo/db/s/flush_routing_table_cache_updates_command.cpp
+++ b/src/mongo/db/s/flush_routing_table_cache_updates_command.cpp
@@ -35,9 +35,9 @@
#include "mongo/db/auth/authorization_manager.h"
#include "mongo/db/auth/authorization_session.h"
#include "mongo/db/auth/privilege.h"
+#include "mongo/db/catalog/catalog_raii.h"
#include "mongo/db/client.h"
#include "mongo/db/commands.h"
-#include "mongo/db/db_raii.h"
#include "mongo/db/operation_context.h"
#include "mongo/db/repl/repl_client_info.h"
#include "mongo/db/s/migration_source_manager.h"
diff --git a/src/mongo/db/s/get_shard_version_command.cpp b/src/mongo/db/s/get_shard_version_command.cpp
index 91c7707eae6..7853b107279 100644
--- a/src/mongo/db/s/get_shard_version_command.cpp
+++ b/src/mongo/db/s/get_shard_version_command.cpp
@@ -35,9 +35,8 @@
#include "mongo/db/auth/authorization_manager.h"
#include "mongo/db/auth/authorization_session.h"
#include "mongo/db/auth/privilege.h"
+#include "mongo/db/catalog/catalog_raii.h"
#include "mongo/db/commands.h"
-#include "mongo/db/db_raii.h"
-#include "mongo/db/s/collection_metadata.h"
#include "mongo/db/s/collection_sharding_state.h"
#include "mongo/db/s/sharded_connection_info.h"
#include "mongo/db/s/sharding_state.h"
diff --git a/src/mongo/db/s/merge_chunks_command.cpp b/src/mongo/db/s/merge_chunks_command.cpp
index f4ec0529dee..a589e580864 100644
--- a/src/mongo/db/s/merge_chunks_command.cpp
+++ b/src/mongo/db/s/merge_chunks_command.cpp
@@ -33,13 +33,11 @@
#include "mongo/db/auth/action_type.h"
#include "mongo/db/auth/authorization_session.h"
#include "mongo/db/auth/privilege.h"
+#include "mongo/db/catalog/catalog_raii.h"
#include "mongo/db/commands.h"
-#include "mongo/db/db_raii.h"
#include "mongo/db/field_parser.h"
#include "mongo/db/namespace_string.h"
-#include "mongo/db/s/collection_metadata.h"
#include "mongo/db/s/collection_sharding_state.h"
-#include "mongo/db/s/metadata_manager.h"
#include "mongo/db/s/sharding_state.h"
#include "mongo/s/catalog/type_chunk.h"
#include "mongo/s/client/shard_registry.h"
diff --git a/src/mongo/db/s/metadata_manager.cpp b/src/mongo/db/s/metadata_manager.cpp
index 3c60b433f0e..60b8edca338 100644
--- a/src/mongo/db/s/metadata_manager.cpp
+++ b/src/mongo/db/s/metadata_manager.cpp
@@ -36,10 +36,8 @@
#include "mongo/bson/simple_bsonobj_comparator.h"
#include "mongo/bson/util/builder.h"
#include "mongo/db/bson/dotted_path_support.h"
-#include "mongo/db/db_raii.h"
#include "mongo/db/query/internal_plans.h"
#include "mongo/db/range_arithmetic.h"
-#include "mongo/db/s/collection_range_deleter.h"
#include "mongo/db/s/collection_sharding_state.h"
#include "mongo/db/s/sharding_state.h"
#include "mongo/stdx/memory.h"
diff --git a/src/mongo/db/s/metadata_manager_test.cpp b/src/mongo/db/s/metadata_manager_test.cpp
index eb0999b6b00..2c09b55c69d 100644
--- a/src/mongo/db/s/metadata_manager_test.cpp
+++ b/src/mongo/db/s/metadata_manager_test.cpp
@@ -32,14 +32,12 @@
#include "mongo/bson/bsonobjbuilder.h"
#include "mongo/client/remote_command_targeter_mock.h"
+#include "mongo/db/catalog/catalog_raii.h"
#include "mongo/db/client.h"
-#include "mongo/db/db_raii.h"
#include "mongo/db/dbdirectclient.h"
#include "mongo/db/jsobj.h"
#include "mongo/db/namespace_string.h"
#include "mongo/db/repl/replication_coordinator_mock.h"
-#include "mongo/db/s/collection_metadata.h"
-#include "mongo/db/s/collection_sharding_state.h"
#include "mongo/db/s/metadata_manager.h"
#include "mongo/db/s/sharding_state.h"
#include "mongo/db/s/type_shard_identity.h"
diff --git a/src/mongo/db/s/migration_chunk_cloner_source_legacy.cpp b/src/mongo/db/s/migration_chunk_cloner_source_legacy.cpp
index 7c1beb1dcce..42bb184d83a 100644
--- a/src/mongo/db/s/migration_chunk_cloner_source_legacy.cpp
+++ b/src/mongo/db/s/migration_chunk_cloner_source_legacy.cpp
@@ -34,9 +34,8 @@
#include "mongo/base/status.h"
#include "mongo/client/read_preference.h"
+#include "mongo/db/catalog/catalog_raii.h"
#include "mongo/db/catalog/index_catalog.h"
-#include "mongo/db/concurrency/locker.h"
-#include "mongo/db/db_raii.h"
#include "mongo/db/dbhelpers.h"
#include "mongo/db/exec/plan_stage.h"
#include "mongo/db/exec/working_set_common.h"
diff --git a/src/mongo/db/s/migration_chunk_cloner_source_legacy_commands.cpp b/src/mongo/db/s/migration_chunk_cloner_source_legacy_commands.cpp
index 41bf7d385cd..2b36c3efa30 100644
--- a/src/mongo/db/s/migration_chunk_cloner_source_legacy_commands.cpp
+++ b/src/mongo/db/s/migration_chunk_cloner_source_legacy_commands.cpp
@@ -35,9 +35,9 @@
#include "mongo/db/auth/authorization_manager.h"
#include "mongo/db/auth/authorization_session.h"
#include "mongo/db/auth/privilege.h"
+#include "mongo/db/catalog/catalog_raii.h"
#include "mongo/db/commands.h"
#include "mongo/db/concurrency/write_conflict_exception.h"
-#include "mongo/db/db_raii.h"
#include "mongo/db/s/collection_sharding_state.h"
#include "mongo/db/s/migration_chunk_cloner_source_legacy.h"
#include "mongo/db/s/migration_source_manager.h"
diff --git a/src/mongo/db/s/migration_chunk_cloner_source_legacy_test.cpp b/src/mongo/db/s/migration_chunk_cloner_source_legacy_test.cpp
index a15f6487a33..4025dbca918 100644
--- a/src/mongo/db/s/migration_chunk_cloner_source_legacy_test.cpp
+++ b/src/mongo/db/s/migration_chunk_cloner_source_legacy_test.cpp
@@ -29,8 +29,7 @@
#include "mongo/platform/basic.h"
#include "mongo/client/remote_command_targeter_mock.h"
-#include "mongo/db/catalog/collection.h"
-#include "mongo/db/db_raii.h"
+#include "mongo/db/catalog/catalog_raii.h"
#include "mongo/db/dbdirectclient.h"
#include "mongo/db/namespace_string.h"
#include "mongo/db/repl/replication_coordinator_mock.h"
diff --git a/src/mongo/db/s/migration_destination_manager.cpp b/src/mongo/db/s/migration_destination_manager.cpp
index 95d6db11dc4..7c06445204e 100644
--- a/src/mongo/db/s/migration_destination_manager.cpp
+++ b/src/mongo/db/s/migration_destination_manager.cpp
@@ -38,9 +38,7 @@
#include "mongo/client/connpool.h"
#include "mongo/db/auth/authorization_manager_global.h"
#include "mongo/db/auth/authorization_session.h"
-#include "mongo/db/catalog/collection.h"
#include "mongo/db/catalog/collection_catalog_entry.h"
-#include "mongo/db/catalog/database.h"
#include "mongo/db/catalog/document_validation.h"
#include "mongo/db/catalog/index_create.h"
#include "mongo/db/db_raii.h"
@@ -50,8 +48,6 @@
#include "mongo/db/ops/delete.h"
#include "mongo/db/repl/repl_client_info.h"
#include "mongo/db/repl/replication_coordinator_global.h"
-#include "mongo/db/s/collection_metadata.h"
-#include "mongo/db/s/collection_range_deleter.h"
#include "mongo/db/s/collection_sharding_state.h"
#include "mongo/db/s/migration_util.h"
#include "mongo/db/s/move_timing_helper.h"
@@ -434,7 +430,8 @@ void MigrationDestinationManager::_migrateThread(BSONObj min,
OID epoch,
WriteConcernOptions writeConcern) {
Client::initThread("migrateThread");
- auto opCtx = getGlobalServiceContext()->makeOperationContext(&cc());
+ auto opCtx = Client::getCurrent()->makeOperationContext();
+
if (getGlobalAuthorizationManager()->isAuthEnabled()) {
AuthorizationSession::get(opCtx->getClient())->grantInternalAuthorization();
@@ -472,6 +469,8 @@ void MigrationDestinationManager::_migrateDriver(OperationContext* opCtx,
invariant(!min.isEmpty());
invariant(!max.isEmpty());
+ auto const serviceContext = opCtx->getServiceContext();
+
log() << "Starting receiving end of migration of chunk " << redact(min) << " -> " << redact(max)
<< " for collection " << _nss.ns() << " from " << fromShardConnString << " at epoch "
<< epoch.toString() << " with session id " << *_sessionId;
@@ -655,7 +654,7 @@ void MigrationDestinationManager::_migrateDriver(OperationContext* opCtx,
for (auto&& infoObj : indexInfoObjs.getValue()) {
// make sure to create index on secondaries as well
- getGlobalServiceContext()->getOpObserver()->onCreateIndex(
+ serviceContext->getOpObserver()->onCreateIndex(
opCtx, collection->ns(), collection->uuid(), infoObj, true /* fromMigrate */);
}
diff --git a/src/mongo/db/s/migration_source_manager.cpp b/src/mongo/db/s/migration_source_manager.cpp
index f42b58daed9..f2618d75107 100644
--- a/src/mongo/db/s/migration_source_manager.cpp
+++ b/src/mongo/db/s/migration_source_manager.cpp
@@ -33,8 +33,8 @@
#include "mongo/db/s/migration_source_manager.h"
#include "mongo/bson/bsonobjbuilder.h"
+#include "mongo/db/catalog/catalog_raii.h"
#include "mongo/db/concurrency/write_conflict_exception.h"
-#include "mongo/db/db_raii.h"
#include "mongo/db/operation_context.h"
#include "mongo/db/s/migration_chunk_cloner_source_legacy.h"
#include "mongo/db/s/migration_util.h"
diff --git a/src/mongo/db/s/move_chunk_command.cpp b/src/mongo/db/s/move_chunk_command.cpp
index a4c894b8a1c..235e053a3f8 100644
--- a/src/mongo/db/s/move_chunk_command.cpp
+++ b/src/mongo/db/s/move_chunk_command.cpp
@@ -36,15 +36,11 @@
#include "mongo/db/auth/authorization_manager.h"
#include "mongo/db/auth/authorization_session.h"
#include "mongo/db/commands.h"
-#include "mongo/db/db_raii.h"
#include "mongo/db/repl/repl_client_info.h"
#include "mongo/db/s/chunk_move_write_concern_options.h"
-#include "mongo/db/s/collection_metadata.h"
-#include "mongo/db/s/collection_sharding_state.h"
#include "mongo/db/s/migration_source_manager.h"
#include "mongo/db/s/move_timing_helper.h"
#include "mongo/db/s/sharding_state.h"
-#include "mongo/s/catalog_cache_loader.h"
#include "mongo/s/client/shard_registry.h"
#include "mongo/s/grid.h"
#include "mongo/s/migration_secondary_throttle_options.h"
@@ -54,9 +50,6 @@
#include "mongo/util/log.h"
namespace mongo {
-
-using std::string;
-
namespace {
/**
@@ -100,7 +93,7 @@ public:
}
Status checkAuthForCommand(Client* client,
- const string& dbname,
+ const std::string& dbname,
const BSONObj& cmdObj) override {
if (!AuthorizationSession::get(client)->isAuthorizedForActionsOnResource(
ResourcePattern::forClusterResource(), ActionType::internal)) {
@@ -109,12 +102,12 @@ public:
return Status::OK();
}
- string parseNs(const string& dbname, const BSONObj& cmdObj) const override {
+ std::string parseNs(const std::string& dbname, const BSONObj& cmdObj) const override {
return parseNsFullyQualified(dbname, cmdObj);
}
bool run(OperationContext* opCtx,
- const string& dbname,
+ const std::string& dbname,
const BSONObj& cmdObj,
BSONObjBuilder& result) override {
auto shardingState = ShardingState::get(opCtx);
@@ -196,7 +189,7 @@ private:
ReadPreferenceSetting{ReadPreference::PrimaryOnly});
}());
- string unusedErrMsg;
+ std::string unusedErrMsg;
MoveTimingHelper moveTimingHelper(opCtx,
"from",
moveChunkRequest.getNss().ns(),
diff --git a/src/mongo/db/s/session_catalog_migration_source.cpp b/src/mongo/db/s/session_catalog_migration_source.cpp
index 9ca38970dc7..e99913c1eeb 100644
--- a/src/mongo/db/s/session_catalog_migration_source.cpp
+++ b/src/mongo/db/s/session_catalog_migration_source.cpp
@@ -30,8 +30,8 @@
#include "mongo/db/s/session_catalog_migration_source.h"
+#include "mongo/db/catalog/catalog_raii.h"
#include "mongo/db/concurrency/write_conflict_exception.h"
-#include "mongo/db/db_raii.h"
#include "mongo/db/dbdirectclient.h"
#include "mongo/db/namespace_string.h"
#include "mongo/db/repl/repl_client_info.h"
@@ -46,7 +46,6 @@
#include "mongo/util/mongoutils/str.h"
namespace mongo {
-
namespace {
PseudoRandom hashGenerator(std::unique_ptr<SecureRandom>(SecureRandom::create())->nextInt64());
diff --git a/src/mongo/db/s/set_shard_version_command.cpp b/src/mongo/db/s/set_shard_version_command.cpp
index 4049a4cae69..61ab7ece2b1 100644
--- a/src/mongo/db/s/set_shard_version_command.cpp
+++ b/src/mongo/db/s/set_shard_version_command.cpp
@@ -35,18 +35,16 @@
#include "mongo/db/auth/authorization_manager.h"
#include "mongo/db/auth/authorization_session.h"
#include "mongo/db/auth/privilege.h"
+#include "mongo/db/catalog/catalog_raii.h"
#include "mongo/db/client.h"
#include "mongo/db/commands.h"
-#include "mongo/db/db_raii.h"
#include "mongo/db/lasterror.h"
#include "mongo/db/operation_context.h"
-#include "mongo/db/repl/replication_coordinator_global.h"
-#include "mongo/db/s/collection_metadata.h"
+#include "mongo/db/repl/replication_coordinator.h"
#include "mongo/db/s/collection_sharding_state.h"
#include "mongo/db/s/migration_source_manager.h"
#include "mongo/db/s/sharded_connection_info.h"
#include "mongo/db/s/sharding_state.h"
-#include "mongo/db/wire_version.h"
#include "mongo/s/chunk_version.h"
#include "mongo/s/client/shard_registry.h"
#include "mongo/s/grid.h"
diff --git a/src/mongo/db/s/sharding_state.cpp b/src/mongo/db/s/sharding_state.cpp
index 16a0627e48b..d4025ea9e11 100644
--- a/src/mongo/db/s/sharding_state.cpp
+++ b/src/mongo/db/s/sharding_state.cpp
@@ -37,15 +37,14 @@
#include "mongo/client/connection_string.h"
#include "mongo/client/replica_set_monitor.h"
#include "mongo/db/auth/authorization_session.h"
+#include "mongo/db/catalog/catalog_raii.h"
#include "mongo/db/client.h"
-#include "mongo/db/db_raii.h"
#include "mongo/db/dbhelpers.h"
#include "mongo/db/operation_context.h"
#include "mongo/db/ops/update.h"
#include "mongo/db/ops/update_lifecycle_impl.h"
#include "mongo/db/repl/optime.h"
-#include "mongo/db/repl/replication_coordinator_global.h"
-#include "mongo/db/s/collection_metadata.h"
+#include "mongo/db/repl/replication_coordinator.h"
#include "mongo/db/s/collection_sharding_state.h"
#include "mongo/db/s/operation_sharding_state.h"
#include "mongo/db/s/sharded_connection_info.h"
@@ -67,11 +66,6 @@
#include "mongo/util/log.h"
#include "mongo/util/mongoutils/str.h"
-#include <chrono>
-#include <ctime>
-#include <iomanip>
-#include <iostream>
-
namespace mongo {
using std::shared_ptr;
@@ -100,7 +94,7 @@ void updateShardIdentityConfigStringCB(const string& setName, const string& newC
}
Client::initThread("updateShardIdentityConfigConnString");
- auto uniqOpCtx = getGlobalServiceContext()->makeOperationContext(&cc());
+ auto uniqOpCtx = Client::getCurrent()->makeOperationContext();
auto status = ShardingState::get(uniqOpCtx.get())
->updateShardIdentityConfigString(uniqOpCtx.get(), newConnectionString);
diff --git a/src/mongo/db/s/sharding_state_recovery.cpp b/src/mongo/db/s/sharding_state_recovery.cpp
index 0f956edb5ae..5b56f7a62c8 100644
--- a/src/mongo/db/s/sharding_state_recovery.cpp
+++ b/src/mongo/db/s/sharding_state_recovery.cpp
@@ -35,7 +35,7 @@
#include "mongo/bson/bsonobj.h"
#include "mongo/bson/bsonobjbuilder.h"
#include "mongo/bson/util/bson_extract.h"
-#include "mongo/db/db_raii.h"
+#include "mongo/db/catalog/catalog_raii.h"
#include "mongo/db/dbhelpers.h"
#include "mongo/db/namespace_string.h"
#include "mongo/db/operation_context.h"
diff --git a/src/mongo/db/s/split_chunk.cpp b/src/mongo/db/s/split_chunk.cpp
index 348e8d1c52b..f37c825dbfd 100644
--- a/src/mongo/db/s/split_chunk.cpp
+++ b/src/mongo/db/s/split_chunk.cpp
@@ -34,9 +34,9 @@
#include "mongo/base/status_with.h"
#include "mongo/bson/util/bson_extract.h"
+#include "mongo/db/catalog/catalog_raii.h"
#include "mongo/db/catalog/index_catalog.h"
#include "mongo/db/commands.h"
-#include "mongo/db/db_raii.h"
#include "mongo/db/dbhelpers.h"
#include "mongo/db/index/index_descriptor.h"
#include "mongo/db/keypattern.h"
diff --git a/src/mongo/db/s/split_vector.cpp b/src/mongo/db/s/split_vector.cpp
index 9aad6ad17b2..3e917524aaf 100644
--- a/src/mongo/db/s/split_vector.cpp
+++ b/src/mongo/db/s/split_vector.cpp
@@ -34,8 +34,8 @@
#include "mongo/base/status_with.h"
#include "mongo/db/bson/dotted_path_support.h"
+#include "mongo/db/catalog/catalog_raii.h"
#include "mongo/db/catalog/index_catalog.h"
-#include "mongo/db/db_raii.h"
#include "mongo/db/dbhelpers.h"
#include "mongo/db/exec/working_set_common.h"
#include "mongo/db/index/index_descriptor.h"