summaryrefslogtreecommitdiff
path: root/src/mongo/db/s/shardsvr_move_range_command.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/s/shardsvr_move_range_command.cpp')
-rw-r--r--src/mongo/db/s/shardsvr_move_range_command.cpp46
1 files changed, 24 insertions, 22 deletions
diff --git a/src/mongo/db/s/shardsvr_move_range_command.cpp b/src/mongo/db/s/shardsvr_move_range_command.cpp
index df6d900aa3c..dab2d3ab073 100644
--- a/src/mongo/db/s/shardsvr_move_range_command.cpp
+++ b/src/mongo/db/s/shardsvr_move_range_command.cpp
@@ -97,7 +97,7 @@ public:
// Check if there is an existing migration running and if so, join it
if (scopedMigration.mustExecute()) {
auto moveChunkComplete =
- ExecutorFuture<void>(_getExecutor())
+ ExecutorFuture<void>(Grid::get(opCtx)->getExecutorPool()->getFixedExecutor())
.then([req = request(),
writeConcern = opCtx->getWriteConcern(),
scopedMigration = std::move(scopedMigration),
@@ -215,6 +215,13 @@ public:
opCtx, ReadPreferenceSetting{ReadPreference::PrimaryOnly});
}());
+ long long totalDocsCloned =
+ ShardingStatistics::get(opCtx).countDocsClonedOnDonor.load();
+ long long totalBytesCloned =
+ ShardingStatistics::get(opCtx).countBytesClonedOnDonor.load();
+ long long totalCloneTime =
+ ShardingStatistics::get(opCtx).totalDonorChunkCloneTimeMillis.load();
+
MigrationSourceManager migrationSourceManager(
opCtx, std::move(request), std::move(writeConcern), donorConnStr, recipientHost);
@@ -223,28 +230,23 @@ public:
migrationSourceManager.enterCriticalSection();
migrationSourceManager.commitChunkOnRecipient();
migrationSourceManager.commitChunkMetadataOnConfig();
- }
-
- // Returns a single-threaded executor to be used to run moveChunk commands. The executor is
- // initialized on the first call to this function. Uses a shared_ptr because a shared_ptr is
- // required to work with ExecutorFutures.
- static std::shared_ptr<ThreadPool> _getExecutor() {
- static Mutex mutex = MONGO_MAKE_LATCH("MoveChunkExecutor::_mutex");
- static std::shared_ptr<ThreadPool> executor;
-
- stdx::lock_guard<Latch> lg(mutex);
- if (!executor) {
- ThreadPool::Options options;
- options.poolName = "MoveChunk";
- options.minThreads = 0;
- // We limit the size of the thread pool to a single thread because currently there
- // can only be one moveRange operation on a shard at a time.
- options.maxThreads = 1;
- executor = std::make_shared<ThreadPool>(std::move(options));
- executor->startup();
- }
- return executor;
+ long long docsCloned =
+ ShardingStatistics::get(opCtx).countDocsClonedOnDonor.load() - totalDocsCloned;
+ long long bytesCloned =
+ ShardingStatistics::get(opCtx).countBytesClonedOnDonor.load() - totalBytesCloned;
+ long long cloneTime =
+ ShardingStatistics::get(opCtx).totalDonorChunkCloneTimeMillis.load() -
+ totalCloneTime;
+ auto migrationId = migrationSourceManager.getMigrationId();
+
+ LOGV2(7627801,
+ "Migration finished",
+ "migrationId"_attr = migrationId ? migrationId->toString() : "",
+ "totalTimeMillis"_attr = migrationSourceManager.getOpTimeMillis(),
+ "docsCloned"_attr = docsCloned,
+ "bytesCloned"_attr = bytesCloned,
+ "cloneTime"_attr = cloneTime);
}
};