diff options
Diffstat (limited to 'src/mongo/db/s')
21 files changed, 227 insertions, 136 deletions
diff --git a/src/mongo/db/s/check_sharding_index_command.cpp b/src/mongo/db/s/check_sharding_index_command.cpp index de1dbf6487c..8f24954949b 100644 --- a/src/mongo/db/s/check_sharding_index_command.cpp +++ b/src/mongo/db/s/check_sharding_index_command.cpp @@ -37,8 +37,8 @@ #include "mongo/db/db_raii.h" #include "mongo/db/dbhelpers.h" #include "mongo/db/exec/working_set_common.h" -#include "mongo/db/index_legacy.h" #include "mongo/db/index/index_descriptor.h" +#include "mongo/db/index_legacy.h" #include "mongo/db/keypattern.h" #include "mongo/db/query/internal_plans.h" #include "mongo/util/log.h" diff --git a/src/mongo/db/s/cleanup_orphaned_cmd.cpp b/src/mongo/db/s/cleanup_orphaned_cmd.cpp index 9ea761808ac..e3abdbb9354 100644 --- a/src/mongo/db/s/cleanup_orphaned_cmd.cpp +++ b/src/mongo/db/s/cleanup_orphaned_cmd.cpp @@ -44,10 +44,10 @@ #include "mongo/db/range_arithmetic.h" #include "mongo/db/range_deleter_service.h" #include "mongo/db/repl/replication_coordinator_global.h" -#include "mongo/db/service_context.h" +#include "mongo/db/s/chunk_move_write_concern_options.h" #include "mongo/db/s/collection_metadata.h" #include "mongo/db/s/sharding_state.h" -#include "mongo/db/s/chunk_move_write_concern_options.h" +#include "mongo/db/service_context.h" #include "mongo/s/migration_secondary_throttle_options.h" #include "mongo/util/log.h" diff --git a/src/mongo/db/s/collection_metadata.cpp b/src/mongo/db/s/collection_metadata.cpp index cc0983eeba5..5c16ace947b 100644 --- a/src/mongo/db/s/collection_metadata.cpp +++ b/src/mongo/db/s/collection_metadata.cpp @@ -270,7 +270,8 @@ StatusWith<std::unique_ptr<CollectionMetadata>> CollectionMetadata::cloneMerge( if (!validStartEnd || !validNoHoles) { return {ErrorCodes::IllegalOperation, stream() << "cannot merge range " << rangeToString(minKey, maxKey) - << ", overlapping chunks " << overlapToString(overlap) + << ", overlapping chunks " + << overlapToString(overlap) << (!validStartEnd ? " do not have the same min and max key" : " are not all adjacent")}; } diff --git a/src/mongo/db/s/collection_metadata_test.cpp b/src/mongo/db/s/collection_metadata_test.cpp index c1ee18605b7..b6861350ed8 100644 --- a/src/mongo/db/s/collection_metadata_test.cpp +++ b/src/mongo/db/s/collection_metadata_test.cpp @@ -116,7 +116,8 @@ TEST_F(NoChunkFixture, IsKeyValid) { ASSERT_TRUE(getCollMetadata().isValidKey(BSON("a" << 3))); ASSERT_FALSE(getCollMetadata().isValidKey(BSON("a" << "abcde" - << "b" << 1))); + << "b" + << 1))); ASSERT_FALSE(getCollMetadata().isValidKey(BSON("c" << "abcde"))); } @@ -333,10 +334,12 @@ protected: BSONObj fooSingle = BSON( ChunkType::name("test.foo-a_10") - << ChunkType::ns("test.foo") << ChunkType::min(BSON("a" << 10)) + << ChunkType::ns("test.foo") + << ChunkType::min(BSON("a" << 10)) << ChunkType::max(BSON("a" << 20)) << ChunkType::DEPRECATED_lastmod(Date_t::fromMillisSinceEpoch(chunkVersion.toLong())) - << ChunkType::DEPRECATED_epoch(epoch) << ChunkType::shard("shard0000")); + << ChunkType::DEPRECATED_epoch(epoch) + << ChunkType::shard("shard0000")); std::vector<BSONObj> chunksToSend{fooSingle}; auto future = launchAsync([this] { @@ -587,10 +590,12 @@ protected: BSONObj fooSingle = BSON( ChunkType::name("test.foo-a_MinKey") - << ChunkType::ns("test.foo") << ChunkType::min(BSON("a" << MINKEY << "b" << MINKEY)) + << ChunkType::ns("test.foo") + << ChunkType::min(BSON("a" << MINKEY << "b" << MINKEY)) << ChunkType::max(BSON("a" << MAXKEY << "b" << MAXKEY)) << ChunkType::DEPRECATED_lastmod(Date_t::fromMillisSinceEpoch(chunkVersion.toLong())) - << ChunkType::DEPRECATED_epoch(epoch) << ChunkType::shard("shard0000")); + << ChunkType::DEPRECATED_epoch(epoch) + << ChunkType::shard("shard0000")); std::vector<BSONObj> chunksToSend{fooSingle}; auto future = launchAsync([this] { @@ -654,16 +659,20 @@ protected: std::vector<BSONObj> chunksToSend; chunksToSend.push_back(BSON( ChunkType::name("test.foo-a_10") - << ChunkType::ns("test.foo") << ChunkType::min(BSON("a" << 10 << "b" << 0)) + << ChunkType::ns("test.foo") + << ChunkType::min(BSON("a" << 10 << "b" << 0)) << ChunkType::max(BSON("a" << 20 << "b" << 0)) << ChunkType::DEPRECATED_lastmod(Date_t::fromMillisSinceEpoch(chunkVersion.toLong())) - << ChunkType::DEPRECATED_epoch(epoch) << ChunkType::shard("shard0000"))); + << ChunkType::DEPRECATED_epoch(epoch) + << ChunkType::shard("shard0000"))); chunksToSend.push_back(BSON( ChunkType::name("test.foo-a_10") - << ChunkType::ns("test.foo") << ChunkType::min(BSON("a" << 30 << "b" << 0)) + << ChunkType::ns("test.foo") + << ChunkType::min(BSON("a" << 30 << "b" << 0)) << ChunkType::max(BSON("a" << 40 << "b" << 0)) << ChunkType::DEPRECATED_lastmod(Date_t::fromMillisSinceEpoch(chunkVersion.toLong())) - << ChunkType::DEPRECATED_epoch(epoch) << ChunkType::shard("shard0000"))); + << ChunkType::DEPRECATED_epoch(epoch) + << ChunkType::shard("shard0000"))); auto future = launchAsync([this] { MetadataLoader loader; @@ -847,30 +856,36 @@ protected: ChunkVersion version(1, 1, epoch); chunksToSend.push_back(BSON( ChunkType::name("x.y-a_MinKey") - << ChunkType::ns("x.y") << ChunkType::min(BSON("a" << MINKEY)) + << ChunkType::ns("x.y") + << ChunkType::min(BSON("a" << MINKEY)) << ChunkType::max(BSON("a" << 10)) << ChunkType::DEPRECATED_lastmod(Date_t::fromMillisSinceEpoch(version.toLong())) - << ChunkType::DEPRECATED_epoch(version.epoch()) << ChunkType::shard("shard0000"))); + << ChunkType::DEPRECATED_epoch(version.epoch()) + << ChunkType::shard("shard0000"))); } { ChunkVersion version(1, 3, epoch); chunksToSend.push_back(BSON( ChunkType::name("x.y-a_10") - << ChunkType::ns("x.y") << ChunkType::min(BSON("a" << 10)) + << ChunkType::ns("x.y") + << ChunkType::min(BSON("a" << 10)) << ChunkType::max(BSON("a" << 20)) << ChunkType::DEPRECATED_lastmod(Date_t::fromMillisSinceEpoch(version.toLong())) - << ChunkType::DEPRECATED_epoch(version.epoch()) << ChunkType::shard("shard0000"))); + << ChunkType::DEPRECATED_epoch(version.epoch()) + << ChunkType::shard("shard0000"))); } { ChunkVersion version(1, 2, epoch); chunksToSend.push_back(BSON( ChunkType::name("x.y-a_30") - << ChunkType::ns("x.y") << ChunkType::min(BSON("a" << 30)) + << ChunkType::ns("x.y") + << ChunkType::min(BSON("a" << 30)) << ChunkType::max(BSON("a" << MAXKEY)) << ChunkType::DEPRECATED_lastmod(Date_t::fromMillisSinceEpoch(version.toLong())) - << ChunkType::DEPRECATED_epoch(version.epoch()) << ChunkType::shard("shard0000"))); + << ChunkType::DEPRECATED_epoch(version.epoch()) + << ChunkType::shard("shard0000"))); } auto future = launchAsync([this] { diff --git a/src/mongo/db/s/collection_sharding_state.cpp b/src/mongo/db/s/collection_sharding_state.cpp index b4c924034a0..bccdf9cf009 100644 --- a/src/mongo/db/s/collection_sharding_state.cpp +++ b/src/mongo/db/s/collection_sharding_state.cpp @@ -131,11 +131,11 @@ void CollectionShardingState::checkShardVersionOrThrow(OperationContext* txn) co ChunkVersion received; ChunkVersion wanted; if (!_checkShardVersionOk(txn, &errmsg, &received, &wanted)) { - throw SendStaleConfigException(_nss.ns(), - str::stream() << "[" << _nss.ns() - << "] shard version not ok: " << errmsg, - received, - wanted); + throw SendStaleConfigException( + _nss.ns(), + str::stream() << "[" << _nss.ns() << "] shard version not ok: " << errmsg, + received, + wanted); } } @@ -246,8 +246,8 @@ bool CollectionShardingState::_checkShardVersionOk(OperationContext* txn, // Set migration critical section on operation sharding state: operation will wait for the // migration to finish before returning failure and retrying. - OperationShardingState::get(txn) - .setMigrationCriticalSection(_sourceMgr->getMigrationCriticalSection()); + OperationShardingState::get(txn).setMigrationCriticalSection( + _sourceMgr->getMigrationCriticalSection()); return false; } diff --git a/src/mongo/db/s/collection_sharding_state_test.cpp b/src/mongo/db/s/collection_sharding_state_test.cpp index 16b2c903b49..c12d4395f7f 100644 --- a/src/mongo/db/s/collection_sharding_state_test.cpp +++ b/src/mongo/db/s/collection_sharding_state_test.cpp @@ -34,12 +34,12 @@ #include "mongo/db/jsobj.h" #include "mongo/db/namespace_string.h" #include "mongo/db/operation_context_noop.h" -#include "mongo/db/service_context_noop.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/db/service_context_noop.h" +#include "mongo/db/service_context_noop.h" #include "mongo/unittest/unittest.h" #include "mongo/util/clock_source_mock.h" diff --git a/src/mongo/db/s/metadata_loader_test.cpp b/src/mongo/db/s/metadata_loader_test.cpp index c0756a8f29b..67ea0317db0 100644 --- a/src/mongo/db/s/metadata_loader_test.cpp +++ b/src/mongo/db/s/metadata_loader_test.cpp @@ -71,7 +71,8 @@ protected: void expectFindOnConfigSendChunksDefault() { BSONObj chunk = BSON( ChunkType::name("test.foo-a_MinKey") - << ChunkType::ns("test.foo") << ChunkType::min(BSON("a" << MINKEY)) + << ChunkType::ns("test.foo") + << ChunkType::min(BSON("a" << MINKEY)) << ChunkType::max(BSON("a" << MAXKEY)) << ChunkType::DEPRECATED_lastmod(Date_t::fromMillisSinceEpoch(_maxCollVersion.toLong())) << ChunkType::DEPRECATED_epoch(_maxCollVersion.epoch()) 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 542c61dc8ce..a36feb23ebf 100644 --- a/src/mongo/db/s/migration_chunk_cloner_source_legacy.cpp +++ b/src/mongo/db/s/migration_chunk_cloner_source_legacy.cpp @@ -49,8 +49,8 @@ #include "mongo/executor/task_executor.h" #include "mongo/executor/task_executor_pool.h" #include "mongo/rpc/get_status_from_command_result.h" -#include "mongo/s/client/shard_registry.h" #include "mongo/s/chunk.h" +#include "mongo/s/client/shard_registry.h" #include "mongo/s/grid.h" #include "mongo/util/elapsed_tracker.h" #include "mongo/util/log.h" @@ -514,7 +514,8 @@ Status MigrationChunkClonerSourceLegacy::_storeCurrentLocs(OperationContext* txn if (!idx) { return {ErrorCodes::IndexNotFound, str::stream() << "can't find index with prefix " << _shardKeyPattern.toBSON() - << " in storeCurrentLocs for " << _args.getNss().ns()}; + << " in storeCurrentLocs for " + << _args.getNss().ns()}; } // Install the stage, which will listen for notifications on the collection @@ -604,10 +605,19 @@ Status MigrationChunkClonerSourceLegacy::_storeCurrentLocs(OperationContext* txn return { ErrorCodes::ChunkTooBig, str::stream() << "Cannot move chunk: the maximum number of documents for a chunk is " - << maxRecsWhenFull << ", the maximum chunk size is " - << _args.getMaxChunkSizeBytes() << ", average document size is " - << avgRecSize << ". Found " << recCount << " documents in chunk " - << " ns: " << _args.getNss().ns() << " " << _args.getMinKey() << " -> " + << maxRecsWhenFull + << ", the maximum chunk size is " + << _args.getMaxChunkSizeBytes() + << ", average document size is " + << avgRecSize + << ". Found " + << recCount + << " documents in chunk " + << " ns: " + << _args.getNss().ns() + << " " + << _args.getMinKey() + << " -> " << _args.getMaxKey()}; } 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 eb72772db1e..7f7850cb22c 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 @@ -38,9 +38,9 @@ #include "mongo/db/commands.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" #include "mongo/db/s/sharding_state.h" -#include "mongo/db/s/migration_chunk_cloner_source_legacy.h" /** * This file contains commands, which are specific to the legacy chunk cloner source. diff --git a/src/mongo/db/s/migration_destination_manager.cpp b/src/mongo/db/s/migration_destination_manager.cpp index 36592d6bd2e..e6990087018 100644 --- a/src/mongo/db/s/migration_destination_manager.cpp +++ b/src/mongo/db/s/migration_destination_manager.cpp @@ -50,13 +50,13 @@ #include "mongo/db/range_deleter_service.h" #include "mongo/db/repl/repl_client_info.h" #include "mongo/db/repl/replication_coordinator_global.h" -#include "mongo/db/service_context.h" -#include "mongo/db/storage/mmap_v1/dur.h" #include "mongo/db/s/collection_metadata.h" #include "mongo/db/s/collection_sharding_state.h" #include "mongo/db/s/move_timing_helper.h" #include "mongo/db/s/sharded_connection_info.h" #include "mongo/db/s/sharding_state.h" +#include "mongo/db/service_context.h" +#include "mongo/db/storage/mmap_v1/dur.h" #include "mongo/logger/ramlog.h" #include "mongo/s/catalog/type_chunk.h" #include "mongo/s/shard_key_pattern.h" @@ -260,8 +260,14 @@ Status MigrationDestinationManager::start(const string& ns, if (_sessionId) { return Status(ErrorCodes::ConflictingOperationInProgress, str::stream() << "Active migration already in progress " - << "ns: " << _ns << ", from: " << _from << ", min: " << _min - << ", max: " << _max); + << "ns: " + << _ns + << ", from: " + << _from + << ", min: " + << _min + << ", max: " + << _max); } _state = READY; @@ -978,9 +984,16 @@ Status MigrationDestinationManager::_notePending(OperationContext* txn, if (!metadata || metadata->getCollVersion().epoch() != epoch) { return {ErrorCodes::StaleShardVersion, str::stream() << "could not note chunk " - << "[" << min << "," << max << ")" - << " as pending because the epoch for " << nss.ns() - << " has changed from " << epoch << " to " + << "[" + << min + << "," + << max + << ")" + << " as pending because the epoch for " + << nss.ns() + << " has changed from " + << epoch + << " to " << (metadata ? metadata->getCollVersion().epoch() : ChunkVersion::UNSHARDED().epoch())}; } @@ -1023,10 +1036,18 @@ Status MigrationDestinationManager::_forgetPending(OperationContext* txn, if (!metadata || metadata->getCollVersion().epoch() != epoch) { return {ErrorCodes::StaleShardVersion, str::stream() << "no need to forget pending chunk " - << "[" << min << "," << max << ")" - << " because the epoch for " << nss.ns() << " has changed from " - << epoch << " to " << (metadata ? metadata->getCollVersion().epoch() - : ChunkVersion::UNSHARDED().epoch())}; + << "[" + << min + << "," + << max + << ")" + << " because the epoch for " + << nss.ns() + << " has changed from " + << epoch + << " to " + << (metadata ? metadata->getCollVersion().epoch() + : ChunkVersion::UNSHARDED().epoch())}; } ChunkType chunk; diff --git a/src/mongo/db/s/migration_session_id_test.cpp b/src/mongo/db/s/migration_session_id_test.cpp index 7cb443207de..02625995941 100644 --- a/src/mongo/db/s/migration_session_id_test.cpp +++ b/src/mongo/db/s/migration_session_id_test.cpp @@ -71,8 +71,9 @@ TEST(MigrationSessionId, Comparison) { } TEST(MigrationSessionId, ErrorWhenTypeIsNotString) { - ASSERT_NOT_OK(MigrationSessionId::extractFromBSON( - BSON("SomeField" << 1 << "sessionId" << Date_t::now())).getStatus()); + ASSERT_NOT_OK( + MigrationSessionId::extractFromBSON(BSON("SomeField" << 1 << "sessionId" << Date_t::now())) + .getStatus()); ASSERT_NOT_OK(MigrationSessionId::extractFromBSON(BSON("SomeField" << 1 << "sessionId" << 2)) .getStatus()); } diff --git a/src/mongo/db/s/migration_source_manager.cpp b/src/mongo/db/s/migration_source_manager.cpp index 109e6cfe8f7..49b07775b28 100644 --- a/src/mongo/db/s/migration_source_manager.cpp +++ b/src/mongo/db/s/migration_source_manager.cpp @@ -35,9 +35,9 @@ #include "mongo/bson/bsonobjbuilder.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/collection_metadata.h" #include "mongo/db/s/collection_sharding_state.h" +#include "mongo/db/s/migration_chunk_cloner_source_legacy.h" #include "mongo/db/s/operation_sharding_state.h" #include "mongo/db/s/sharding_state.h" #include "mongo/db/s/sharding_state_recovery.h" @@ -91,8 +91,12 @@ MigrationSourceManager::MigrationSourceManager(OperationContext* txn, MoveChunkR if (!refreshStatus.isOK()) { uasserted(refreshStatus.code(), str::stream() << "moveChunk cannot start migrate of chunk " - << "[" << _args.getMinKey() << "," << _args.getMaxKey() - << ") due to " << refreshStatus.toString()); + << "[" + << _args.getMinKey() + << "," + << _args.getMaxKey() + << ") due to " + << refreshStatus.toString()); } if (shardVersion.majorVersion() == 0) { @@ -100,20 +104,29 @@ MigrationSourceManager::MigrationSourceManager(OperationContext* txn, MoveChunkR // the first place uasserted(ErrorCodes::IncompatibleShardingMetadata, str::stream() << "moveChunk cannot start migrate of chunk " - << "[" << _args.getMinKey() << "," << _args.getMaxKey() << ")" + << "[" + << _args.getMinKey() + << "," + << _args.getMaxKey() + << ")" << " with zero shard version"); } if (expectedCollectionVersion.epoch() != shardVersion.epoch()) { - throw SendStaleConfigException( - _args.getNss().ns(), - str::stream() << "moveChunk cannot move chunk " - << "[" << _args.getMinKey() << "," << _args.getMaxKey() << "), " - << "collection may have been dropped. " - << "current epoch: " << shardVersion.epoch() - << ", cmd epoch: " << expectedCollectionVersion.epoch(), - expectedCollectionVersion, - shardVersion); + throw SendStaleConfigException(_args.getNss().ns(), + str::stream() << "moveChunk cannot move chunk " + << "[" + << _args.getMinKey() + << "," + << _args.getMaxKey() + << "), " + << "collection may have been dropped. " + << "current epoch: " + << shardVersion.epoch() + << ", cmd epoch: " + << expectedCollectionVersion.epoch(), + expectedCollectionVersion, + shardVersion); } // Snapshot the committed metadata from the time the migration starts @@ -137,13 +150,17 @@ MigrationSourceManager::MigrationSourceManager(OperationContext* txn, MoveChunkR origChunk.getMin().woCompare(_args.getMinKey()) || origChunk.getMax().woCompare(_args.getMaxKey())) { // Our boundaries are different from those passed in - throw SendStaleConfigException( - _args.getNss().ns(), - str::stream() << "moveChunk cannot find chunk " - << "[" << _args.getMinKey() << "," << _args.getMaxKey() << ")" - << " to migrate, the chunk boundaries may be stale", - expectedCollectionVersion, - shardVersion); + throw SendStaleConfigException(_args.getNss().ns(), + str::stream() + << "moveChunk cannot find chunk " + << "[" + << _args.getMinKey() + << "," + << _args.getMaxKey() + << ")" + << " to migrate, the chunk boundaries may be stale", + expectedCollectionVersion, + shardVersion); } } @@ -160,12 +177,14 @@ Status MigrationSourceManager::startClone(OperationContext* txn) { invariant(_state == kCreated); auto scopedGuard = MakeGuard([&] { cleanupOnError(txn); }); - grid.catalogManager(txn) - ->logChange(txn, - "moveChunk.start", - _args.getNss().ns(), - BSON("min" << _args.getMinKey() << "max" << _args.getMaxKey() << "from" - << _args.getFromShardId() << "to" << _args.getToShardId())); + grid.catalogManager(txn)->logChange( + txn, + "moveChunk.start", + _args.getNss().ns(), + BSON("min" << _args.getMinKey() << "max" << _args.getMaxKey() << "from" + << _args.getFromShardId() + << "to" + << _args.getToShardId())); _cloneDriver = stdx::make_unique<MigrationChunkClonerSourceLegacy>( _args, _committedMetadata->getKeyPattern()); @@ -228,7 +247,8 @@ Status MigrationSourceManager::enterCriticalSection(OperationContext* txn) { str::stream() << "Sharding metadata changed while holding distributed lock. Expected: " << _committedMetadata->getCollVersion().toString() - << ", actual: " << css->getMetadata()->getCollVersion().toString()}; + << ", actual: " + << css->getMetadata()->getCollVersion().toString()}; } // IMPORTANT: After this line, the critical section is in place and needs to be rolled back @@ -394,15 +414,20 @@ Status MigrationSourceManager::commitDonateChunk(OperationContext* txn) { "moveChunk.validating", _args.getNss().ns(), BSON("min" << _args.getMinKey() << "max" << _args.getMaxKey() << "from" - << _args.getFromShardId() << "to" << _args.getToShardId())); + << _args.getFromShardId() + << "to" + << _args.getToShardId())); if (!status.isOK()) { - fassertStatusOK(40137, - {status.code(), - str::stream() - << "applyOps failed to commit chunk [" << _args.getMinKey() << "," - << _args.getMaxKey() << ") due to " << causedBy(applyOpsStatus) - << ", and updating the optime with a write before refreshing the " - << "metadata also failed: " << causedBy(status)}); + fassertStatusOK( + 40137, + {status.code(), + str::stream() << "applyOps failed to commit chunk [" << _args.getMinKey() << "," + << _args.getMaxKey() + << ") due to " + << causedBy(applyOpsStatus) + << ", and updating the optime with a write before refreshing the " + << "metadata also failed: " + << causedBy(status)}); } ShardingState* const shardingState = ShardingState::get(txn); @@ -412,7 +437,9 @@ Status MigrationSourceManager::commitDonateChunk(OperationContext* txn) { fassertStatusOK(34431, {refreshStatus.code(), str::stream() << "applyOps failed to commit chunk [" << _args.getMinKey() - << "," << _args.getMaxKey() << ") due to " + << "," + << _args.getMaxKey() + << ") due to " << causedBy(applyOpsStatus) << ", and refreshing collection metadata failed: " << causedBy(refreshStatus)}); @@ -455,12 +482,14 @@ Status MigrationSourceManager::commitDonateChunk(OperationContext* txn) { scopedGuard.Dismiss(); _cleanup(txn); - grid.catalogManager(txn) - ->logChange(txn, - "moveChunk.commit", - _args.getNss().ns(), - BSON("min" << _args.getMinKey() << "max" << _args.getMaxKey() << "from" - << _args.getFromShardId() << "to" << _args.getToShardId())); + grid.catalogManager(txn)->logChange( + txn, + "moveChunk.commit", + _args.getNss().ns(), + BSON("min" << _args.getMinKey() << "max" << _args.getMaxKey() << "from" + << _args.getFromShardId() + << "to" + << _args.getToShardId())); return Status::OK(); } @@ -470,12 +499,14 @@ void MigrationSourceManager::cleanupOnError(OperationContext* txn) { return; } - grid.catalogManager(txn) - ->logChange(txn, - "moveChunk.error", - _args.getNss().ns(), - BSON("min" << _args.getMinKey() << "max" << _args.getMaxKey() << "from" - << _args.getFromShardId() << "to" << _args.getToShardId())); + grid.catalogManager(txn)->logChange( + txn, + "moveChunk.error", + _args.getNss().ns(), + BSON("min" << _args.getMinKey() << "max" << _args.getMaxKey() << "from" + << _args.getFromShardId() + << "to" + << _args.getToShardId())); _cleanup(txn); } diff --git a/src/mongo/db/s/move_chunk_command.cpp b/src/mongo/db/s/move_chunk_command.cpp index 42beb940283..decb11713ca 100644 --- a/src/mongo/db/s/move_chunk_command.cpp +++ b/src/mongo/db/s/move_chunk_command.cpp @@ -90,9 +90,10 @@ private: */ DistLockManager::ScopedDistLock _acquireDistLock(OperationContext* txn, const MoveChunkRequest& args) { - const std::string whyMessage(str::stream() << "migrating chunk [" << args.getMinKey() - << ", " << args.getMaxKey() << ") in " - << args.getNss().ns()); + const std::string whyMessage( + str::stream() << "migrating chunk [" << args.getMinKey() << ", " << args.getMaxKey() + << ") in " + << args.getNss().ns()); auto distLockStatus = grid.catalogManager(txn)->distLock(txn, args.getNss().ns(), whyMessage); if (!distLockStatus.isOK()) { diff --git a/src/mongo/db/s/move_timing_helper.cpp b/src/mongo/db/s/move_timing_helper.cpp index 68a9c83c9f3..4ff91d6e658 100644 --- a/src/mongo/db/s/move_timing_helper.cpp +++ b/src/mongo/db/s/move_timing_helper.cpp @@ -82,8 +82,8 @@ MoveTimingHelper::~MoveTimingHelper() { _b.append("errmsg", *_cmdErrmsg); } - grid.catalogManager(_txn) - ->logChange(_txn, str::stream() << "moveChunk." << _where, _ns, _b.obj()); + grid.catalogManager(_txn)->logChange( + _txn, str::stream() << "moveChunk." << _where, _ns, _b.obj()); } catch (const std::exception& e) { warning() << "couldn't record timing for moveChunk '" << _where << "': " << e.what(); } diff --git a/src/mongo/db/s/sharding_initialization_mongod.cpp b/src/mongo/db/s/sharding_initialization_mongod.cpp index fc75b886961..08bbce81b8c 100644 --- a/src/mongo/db/s/sharding_initialization_mongod.cpp +++ b/src/mongo/db/s/sharding_initialization_mongod.cpp @@ -36,9 +36,9 @@ #include "mongo/client/remote_command_targeter.h" #include "mongo/client/remote_command_targeter_factory_impl.h" #include "mongo/s/balancer/balancer_configuration.h" -#include "mongo/s/client/shard_remote.h" -#include "mongo/s/client/shard_local.h" #include "mongo/s/client/shard_factory.h" +#include "mongo/s/client/shard_local.h" +#include "mongo/s/client/shard_remote.h" #include "mongo/s/sharding_egress_metadata_hook_for_mongod.h" #include "mongo/s/sharding_initialization.h" #include "mongo/stdx/memory.h" @@ -61,10 +61,10 @@ Status initializeGlobalShardingStateForMongod(const ConnectionString& configCS) shardId, connStr, targeterFactoryPtr->create(connStr)); }; - ShardFactory::BuilderCallable localBuilder = - [](const ShardId& shardId, const ConnectionString& connStr) { - return stdx::make_unique<ShardLocal>(shardId); - }; + ShardFactory::BuilderCallable localBuilder = [](const ShardId& shardId, + const ConnectionString& connStr) { + return stdx::make_unique<ShardLocal>(shardId); + }; ShardFactory::BuildersMap buildersMap{ {ConnectionString::SET, std::move(setBuilder)}, @@ -76,9 +76,8 @@ Status initializeGlobalShardingStateForMongod(const ConnectionString& configCS) stdx::make_unique<ShardFactory>(std::move(buildersMap), std::move(targeterFactory)); return initializeGlobalShardingState( - configCS, - ChunkSizeSettingsType::kDefaultMaxChunkSizeBytes, - std::move(shardFactory), - []() { return stdx::make_unique<rpc::ShardingEgressMetadataHookForMongod>(); }); + configCS, ChunkSizeSettingsType::kDefaultMaxChunkSizeBytes, std::move(shardFactory), []() { + return stdx::make_unique<rpc::ShardingEgressMetadataHookForMongod>(); + }); } } diff --git a/src/mongo/db/s/sharding_state.cpp b/src/mongo/db/s/sharding_state.cpp index fbb6f0f2e62..1a66f122329 100644 --- a/src/mongo/db/s/sharding_state.cpp +++ b/src/mongo/db/s/sharding_state.cpp @@ -54,18 +54,18 @@ #include "mongo/rpc/metadata/config_server_metadata.h" #include "mongo/s/catalog/catalog_manager.h" #include "mongo/s/catalog/type_chunk.h" -#include "mongo/s/client/shard_registry.h" #include "mongo/s/chunk_version.h" +#include "mongo/s/client/shard_registry.h" #include "mongo/s/config.h" #include "mongo/s/grid.h" #include "mongo/s/sharding_initialization.h" #include "mongo/util/log.h" #include "mongo/util/mongoutils/str.h" -#include <iostream> -#include <iomanip> -#include <ctime> #include <chrono> +#include <ctime> +#include <iomanip> +#include <iostream> namespace mongo { @@ -462,7 +462,8 @@ Status ShardingState::initializeFromShardIdentity(const ShardIdentityType& shard if (_shardName != shardIdentity.getShardName()) { return {ErrorCodes::InconsistentShardIdentity, str::stream() << "shard name previously set as " << _shardName - << " is different from stored: " << shardIdentity.getShardName()}; + << " is different from stored: " + << shardIdentity.getShardName()}; } auto prevConfigsvrConnStr = grid.shardRegistry()->getConfigServerConnectionString(); @@ -477,7 +478,8 @@ Status ShardingState::initializeFromShardIdentity(const ShardIdentityType& shard return {ErrorCodes::InconsistentShardIdentity, str::stream() << "config server connection string previously set as " << prevConfigsvrConnStr.toString() - << " is different from stored: " << configSvrConnStr.toString()}; + << " is different from stored: " + << configSvrConnStr.toString()}; } // clusterId will only be unset if sharding state was initialized via the sharding @@ -487,7 +489,8 @@ Status ShardingState::initializeFromShardIdentity(const ShardIdentityType& shard } else if (_clusterId != shardIdentity.getClusterId()) { return {ErrorCodes::InconsistentShardIdentity, str::stream() << "cluster id previously set as " << _clusterId - << " is different from stored: " << shardIdentity.getClusterId()}; + << " is different from stored: " + << shardIdentity.getClusterId()}; } return Status::OK(); diff --git a/src/mongo/db/s/sharding_state_recovery.cpp b/src/mongo/db/s/sharding_state_recovery.cpp index 1574f611403..d076b995f53 100644 --- a/src/mongo/db/s/sharding_state_recovery.cpp +++ b/src/mongo/db/s/sharding_state_recovery.cpp @@ -40,9 +40,9 @@ #include "mongo/db/dbhelpers.h" #include "mongo/db/namespace_string.h" #include "mongo/db/operation_context.h" +#include "mongo/db/ops/update.h" #include "mongo/db/ops/update_lifecycle_impl.h" #include "mongo/db/ops/update_request.h" -#include "mongo/db/ops/update.h" #include "mongo/db/repl/bson_extract_optime.h" #include "mongo/db/repl/optime.h" #include "mongo/db/repl/repl_client_info.h" diff --git a/src/mongo/db/s/sharding_state_test.cpp b/src/mongo/db/s/sharding_state_test.cpp index 5c710d352da..94b26b1f0b7 100644 --- a/src/mongo/db/s/sharding_state_test.cpp +++ b/src/mongo/db/s/sharding_state_test.cpp @@ -29,26 +29,26 @@ #include "mongo/platform/basic.h" #include "mongo/base/status_with.h" +#include "mongo/client/remote_command_targeter.h" #include "mongo/client/remote_command_targeter_factory_mock.h" #include "mongo/client/remote_command_targeter_mock.h" -#include "mongo/client/remote_command_targeter.h" #include "mongo/client/replica_set_monitor.h" -#include "mongo/db/service_context_noop.h" -#include "mongo/executor/network_interface_mock.h" -#include "mongo/executor/thread_pool_task_executor_test_fixture.h" #include "mongo/db/jsobj.h" #include "mongo/db/namespace_string.h" #include "mongo/db/operation_context_noop.h" #include "mongo/db/s/sharding_state.h" #include "mongo/db/s/type_shard_identity.h" #include "mongo/db/service_context_noop.h" +#include "mongo/db/service_context_noop.h" +#include "mongo/executor/network_interface_mock.h" #include "mongo/executor/task_executor_pool.h" +#include "mongo/executor/thread_pool_task_executor_test_fixture.h" #include "mongo/s/balancer/balancer_configuration.h" #include "mongo/s/catalog/catalog_cache.h" #include "mongo/s/catalog/catalog_manager_mock.h" #include "mongo/s/client/shard_factory.h" -#include "mongo/s/client/shard_remote.h" #include "mongo/s/client/shard_registry.h" +#include "mongo/s/client/shard_remote.h" #include "mongo/s/grid.h" #include "mongo/s/query/cluster_cursor_manager.h" #include "mongo/unittest/unittest.h" diff --git a/src/mongo/db/s/split_chunk_command.cpp b/src/mongo/db/s/split_chunk_command.cpp index 7e3473299f3..58018441072 100644 --- a/src/mongo/db/s/split_chunk_command.cpp +++ b/src/mongo/db/s/split_chunk_command.cpp @@ -220,7 +220,8 @@ public: // const string whyMessage(str::stream() << "splitting chunk [" << min << ", " << max - << ") in " << nss.toString()); + << ") in " + << nss.toString()); auto scopedDistLock = grid.catalogManager(txn)->distLock( txn, nss.ns(), whyMessage, DistLockManager::kSingleLockAttemptTimeout); if (!scopedDistLock.isOK()) { @@ -453,8 +454,8 @@ public: chunkDetail.append("of", newChunksSize); appendShortVersion(chunkDetail.subobjStart("chunk"), *newChunks[i]); - grid.catalogManager(txn) - ->logChange(txn, "multi-split", nss.ns(), chunkDetail.obj()); + grid.catalogManager(txn)->logChange( + txn, "multi-split", nss.ns(), chunkDetail.obj()); } } diff --git a/src/mongo/db/s/start_chunk_clone_request_test.cpp b/src/mongo/db/s/start_chunk_clone_request_test.cpp index 5071ff61edc..2b977178781 100644 --- a/src/mongo/db/s/start_chunk_clone_request_test.cpp +++ b/src/mongo/db/s/start_chunk_clone_request_test.cpp @@ -65,9 +65,10 @@ TEST(StartChunkCloneRequest, CreateAsCommandComplete) { ASSERT_EQ(sessionId.toString(), request.getSessionId().toString()); ASSERT(sessionId.matches(request.getSessionId())); ASSERT_EQ("TestConfigRS/CS1:12345,CS2:12345,CS3:12345", request.getConfigServerCS().toString()); - ASSERT_EQ(assertGet(ConnectionString::parse( - "TestDonorRS/Donor1:12345,Donor2:12345,Donor3:12345")).toString(), - request.getFromShardConnectionString().toString()); + ASSERT_EQ( + assertGet(ConnectionString::parse("TestDonorRS/Donor1:12345,Donor2:12345,Donor3:12345")) + .toString(), + request.getFromShardConnectionString().toString()); ASSERT_EQ("shard0002", request.getToShardId()); ASSERT_EQ(BSON("Key" << -100), request.getMinKey()); ASSERT_EQ(BSON("Key" << 100), request.getMaxKey()); diff --git a/src/mongo/db/s/type_shard_identity_test.cpp b/src/mongo/db/s/type_shard_identity_test.cpp index 8a2382e4bf7..960faff68ba 100644 --- a/src/mongo/db/s/type_shard_identity_test.cpp +++ b/src/mongo/db/s/type_shard_identity_test.cpp @@ -47,7 +47,8 @@ TEST(ShardIdentityType, RoundTrip) { << "test/a:123" << "shardName" << "s1" - << "clusterId" << clusterId); + << "clusterId" + << clusterId); auto result = ShardIdentityType::fromBSON(doc); ASSERT_OK(result.getStatus()); @@ -68,7 +69,8 @@ TEST(ShardIdentityType, ParseMissingId) { << "test/a:123" << "shardName" << "s1" - << "clusterId" << OID::gen()); + << "clusterId" + << OID::gen()); auto result = ShardIdentityType::fromBSON(doc); ASSERT_NOT_OK(result.getStatus()); @@ -79,7 +81,8 @@ TEST(ShardIdentityType, ParseMissingConfigsvrConnString) { << "shardIdentity" << "shardName" << "s1" - << "clusterId" << OID::gen()); + << "clusterId" + << OID::gen()); auto result = ShardIdentityType::fromBSON(doc); ASSERT_NOT_OK(result.getStatus()); @@ -90,7 +93,8 @@ TEST(ShardIdentityType, ParseMissingShardName) { << "shardIdentity" << "configsvrConnectionString" << "test/a:123" - << "clusterId" << OID::gen()); + << "clusterId" + << OID::gen()); auto result = ShardIdentityType::fromBSON(doc); ASSERT_NOT_OK(result.getStatus()); @@ -116,7 +120,8 @@ TEST(ShardIdentityType, InvalidConnectionString) { << "test/,,," << "shardName" << "s1" - << "clusterId" << clusterId); + << "clusterId" + << clusterId); ASSERT_EQ(ErrorCodes::FailedToParse, ShardIdentityType::fromBSON(doc).getStatus()); } @@ -129,7 +134,8 @@ TEST(ShardIdentityType, NonReplSetConnectionString) { << "local:123" << "shardName" << "s1" - << "clusterId" << clusterId); + << "clusterId" + << clusterId); ASSERT_EQ(ErrorCodes::UnsupportedFormat, ShardIdentityType::fromBSON(doc).getStatus()); } |