From 1ed034b959e15d5882a0dda072eef3435678248b Mon Sep 17 00:00:00 2001 From: Judah Schvimer Date: Tue, 26 Apr 2016 17:57:24 -0400 Subject: SERVER-23340 Turn off secondaryThrottle by default --- src/mongo/db/s/chunk_move_write_concern_options.cpp | 15 +++++++++++++-- src/mongo/db/s/chunk_move_write_concern_options.h | 3 ++- src/mongo/db/s/cleanup_orphaned_cmd.cpp | 2 +- .../s/migration_destination_manager_legacy_commands.cpp | 2 +- src/mongo/db/s/move_chunk_command.cpp | 2 +- 5 files changed, 18 insertions(+), 6 deletions(-) (limited to 'src/mongo/db/s') diff --git a/src/mongo/db/s/chunk_move_write_concern_options.cpp b/src/mongo/db/s/chunk_move_write_concern_options.cpp index 4005e50106c..32ecdaf56dc 100644 --- a/src/mongo/db/s/chunk_move_write_concern_options.cpp +++ b/src/mongo/db/s/chunk_move_write_concern_options.cpp @@ -33,7 +33,9 @@ #include "mongo/db/s/chunk_move_write_concern_options.h" #include "mongo/base/status_with.h" +#include "mongo/db/operation_context.h" #include "mongo/db/repl/replication_coordinator_global.h" +#include "mongo/db/service_context.h" #include "mongo/s/migration_secondary_throttle_options.h" #include "mongo/util/log.h" @@ -64,8 +66,17 @@ WriteConcernOptions getDefaultWriteConcernForMigration() { } // namespace StatusWith ChunkMoveWriteConcernOptions::getEffectiveWriteConcern( - const MigrationSecondaryThrottleOptions& options) { - if (options.getSecondaryThrottle() == MigrationSecondaryThrottleOptions::kOff) { + OperationContext* txn, const MigrationSecondaryThrottleOptions& options) { + auto secondaryThrottle = options.getSecondaryThrottle(); + if (secondaryThrottle == MigrationSecondaryThrottleOptions::kDefault) { + if (txn->getServiceContext()->getGlobalStorageEngine()->supportsDocLocking()) { + secondaryThrottle = MigrationSecondaryThrottleOptions::kOff; + } else { + secondaryThrottle = MigrationSecondaryThrottleOptions::kOn; + } + } + + if (secondaryThrottle == MigrationSecondaryThrottleOptions::kOff) { return kWriteConcernLocal; } diff --git a/src/mongo/db/s/chunk_move_write_concern_options.h b/src/mongo/db/s/chunk_move_write_concern_options.h index 1ff445d9894..b9734120b2a 100644 --- a/src/mongo/db/s/chunk_move_write_concern_options.h +++ b/src/mongo/db/s/chunk_move_write_concern_options.h @@ -35,6 +35,7 @@ namespace mongo { class MigrationSecondaryThrottleOptions; template class StatusWith; +class OperationContext; /** * Returns the default write concern for migration cleanup on the donor shard and for cloning @@ -59,7 +60,7 @@ public: * concern. */ static StatusWith getEffectiveWriteConcern( - const MigrationSecondaryThrottleOptions& options); + OperationContext* txn, const MigrationSecondaryThrottleOptions& options); }; } // namespace mongo diff --git a/src/mongo/db/s/cleanup_orphaned_cmd.cpp b/src/mongo/db/s/cleanup_orphaned_cmd.cpp index 9421784b28c..9ea761808ac 100644 --- a/src/mongo/db/s/cleanup_orphaned_cmd.cpp +++ b/src/mongo/db/s/cleanup_orphaned_cmd.cpp @@ -228,7 +228,7 @@ public: const auto secondaryThrottle = uassertStatusOK(MigrationSecondaryThrottleOptions::createFromCommand(cmdObj)); const auto writeConcern = uassertStatusOK( - ChunkMoveWriteConcernOptions::getEffectiveWriteConcern(secondaryThrottle)); + ChunkMoveWriteConcernOptions::getEffectiveWriteConcern(txn, secondaryThrottle)); ShardingState* const shardingState = ShardingState::get(txn); diff --git a/src/mongo/db/s/migration_destination_manager_legacy_commands.cpp b/src/mongo/db/s/migration_destination_manager_legacy_commands.cpp index 1d1e5fa40c1..545925f7190 100644 --- a/src/mongo/db/s/migration_destination_manager_legacy_commands.cpp +++ b/src/mongo/db/s/migration_destination_manager_legacy_commands.cpp @@ -155,7 +155,7 @@ public: const auto secondaryThrottle = uassertStatusOK(MigrationSecondaryThrottleOptions::createFromCommand(cmdObj)); const auto writeConcern = uassertStatusOK( - ChunkMoveWriteConcernOptions::getEffectiveWriteConcern(secondaryThrottle)); + ChunkMoveWriteConcernOptions::getEffectiveWriteConcern(txn, secondaryThrottle)); BSONObj shardKeyPattern = cmdObj["shardKeyPattern"].Obj().getOwned(); diff --git a/src/mongo/db/s/move_chunk_command.cpp b/src/mongo/db/s/move_chunk_command.cpp index a3295e974b7..42beb940283 100644 --- a/src/mongo/db/s/move_chunk_command.cpp +++ b/src/mongo/db/s/move_chunk_command.cpp @@ -191,7 +191,7 @@ public: const auto writeConcernForRangeDeleter = uassertStatusOK(ChunkMoveWriteConcernOptions::getEffectiveWriteConcern( - moveChunkRequest.getSecondaryThrottle())); + txn, moveChunkRequest.getSecondaryThrottle())); // Make sure we're as up-to-date as possible with shard information. This catches the case // where we might have changed a shard's host by removing/adding a shard with the same name. -- cgit v1.2.1