summaryrefslogtreecommitdiff
path: root/src/mongo/db
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db')
-rw-r--r--src/mongo/db/s/balancer/balancer.cpp7
-rw-r--r--src/mongo/db/s/balancer/balancer_commands_scheduler_impl.cpp30
2 files changed, 18 insertions, 19 deletions
diff --git a/src/mongo/db/s/balancer/balancer.cpp b/src/mongo/db/s/balancer/balancer.cpp
index 615321b74cf..63cefbbbbfb 100644
--- a/src/mongo/db/s/balancer/balancer.cpp
+++ b/src/mongo/db/s/balancer/balancer.cpp
@@ -45,6 +45,7 @@
#include "mongo/db/client.h"
#include "mongo/db/namespace_string.h"
#include "mongo/db/operation_context.h"
+#include "mongo/db/repl/repl_client_info.h"
#include "mongo/db/s/balancer/balancer_chunk_merger_impl.h"
#include "mongo/db/s/balancer/balancer_chunk_selection_policy_impl.h"
#include "mongo/db/s/balancer/balancer_commands_scheduler_impl.h"
@@ -169,6 +170,12 @@ Status processManualMigrationOutcome(OperationContext* opCtx,
const NamespaceString& nss,
const ShardId& destination,
Status outcome) {
+ // Since the commands scheduler uses a separate thread to remotely execute a
+ // request, the resulting clusterTime needs to be explicitly retrieved and set on the
+ // original context of the requestor to ensure it will be propagated back to the router.
+ auto& replClient = repl::ReplClientInfo::forClient(opCtx->getClient());
+ replClient.setLastOpToSystemLastOpTime(opCtx);
+
if (outcome.isOK()) {
return outcome;
}
diff --git a/src/mongo/db/s/balancer/balancer_commands_scheduler_impl.cpp b/src/mongo/db/s/balancer/balancer_commands_scheduler_impl.cpp
index 0aa98784b35..30670ad8fb0 100644
--- a/src/mongo/db/s/balancer/balancer_commands_scheduler_impl.cpp
+++ b/src/mongo/db/s/balancer/balancer_commands_scheduler_impl.cpp
@@ -32,7 +32,6 @@
#include "mongo/db/s/balancer/balancer_commands_scheduler_impl.h"
#include "mongo/db/client.h"
#include "mongo/db/dbdirectclient.h"
-#include "mongo/db/repl/repl_client_info.h"
#include "mongo/logv2/log.h"
#include "mongo/s/catalog/type_chunk.h"
#include "mongo/s/grid.h"
@@ -48,14 +47,7 @@ namespace {
MONGO_FAIL_POINT_DEFINE(pauseSubmissionsFailPoint);
MONGO_FAIL_POINT_DEFINE(deferredCleanupCompletedCheckpoint);
-Status processRemoteResponse(OperationContext* opCtx,
- const executor::RemoteCommandResponse& remoteResponse) {
- // Since requests are executed by a separate thread, the related operationTime needs to be
- // explicitly retrieved and set on the original context of the requestor to ensure
- // it will be propagated back to the router.
- auto& replClient = repl::ReplClientInfo::forClient(opCtx->getClient());
- replClient.setLastOpToSystemLastOpTime(opCtx);
-
+Status processRemoteResponse(const executor::RemoteCommandResponse& remoteResponse) {
if (!remoteResponse.status.isOK()) {
return remoteResponse.status;
}
@@ -151,8 +143,8 @@ SemiFuture<void> BalancerCommandsSchedulerImpl::requestMoveChunk(
std::move(externalClientInfo));
return _buildAndEnqueueNewRequest(opCtx, std::move(commandInfo))
- .then([opCtx](const executor::RemoteCommandResponse& remoteResponse) {
- return processRemoteResponse(opCtx, remoteResponse);
+ .then([](const executor::RemoteCommandResponse& remoteResponse) {
+ return processRemoteResponse(remoteResponse);
})
.semi();
}
@@ -167,8 +159,8 @@ SemiFuture<void> BalancerCommandsSchedulerImpl::requestMergeChunks(OperationCont
nss, shardId, chunkRange.getMin(), chunkRange.getMax(), version);
return _buildAndEnqueueNewRequest(opCtx, std::move(commandInfo))
- .then([opCtx](const executor::RemoteCommandResponse& remoteResponse) {
- return processRemoteResponse(opCtx, remoteResponse);
+ .then([](const executor::RemoteCommandResponse& remoteResponse) {
+ return processRemoteResponse(remoteResponse);
})
.semi();
}
@@ -184,9 +176,9 @@ SemiFuture<std::vector<BSONObj>> BalancerCommandsSchedulerImpl::requestAutoSplit
auto commandInfo = std::make_shared<AutoSplitVectorCommandInfo>(
nss, shardId, keyPattern, minKey, maxKey, maxChunkSizeBytes);
return _buildAndEnqueueNewRequest(opCtx, std::move(commandInfo))
- .then([opCtx](const executor::RemoteCommandResponse& remoteResponse)
+ .then([](const executor::RemoteCommandResponse& remoteResponse)
-> StatusWith<std::vector<BSONObj>> {
- auto responseStatus = processRemoteResponse(opCtx, remoteResponse);
+ auto responseStatus = processRemoteResponse(remoteResponse);
if (!responseStatus.isOK()) {
return responseStatus;
}
@@ -211,8 +203,8 @@ SemiFuture<void> BalancerCommandsSchedulerImpl::requestSplitChunk(
nss, shardId, keyPattern.toBSON(), minKey, maxKey, collectionVersion, splitPoints);
return _buildAndEnqueueNewRequest(opCtx, std::move(commandInfo))
- .then([opCtx](const executor::RemoteCommandResponse& remoteResponse) {
- return processRemoteResponse(opCtx, remoteResponse);
+ .then([](const executor::RemoteCommandResponse& remoteResponse) {
+ return processRemoteResponse(remoteResponse);
})
.semi();
}
@@ -234,9 +226,9 @@ SemiFuture<DataSizeResponse> BalancerCommandsSchedulerImpl::requestDataSize(
version);
return _buildAndEnqueueNewRequest(opCtx, std::move(commandInfo))
- .then([opCtx](const executor::RemoteCommandResponse& remoteResponse)
+ .then([](const executor::RemoteCommandResponse& remoteResponse)
-> StatusWith<DataSizeResponse> {
- auto responseStatus = processRemoteResponse(opCtx, remoteResponse);
+ auto responseStatus = processRemoteResponse(remoteResponse);
if (!responseStatus.isOK()) {
return responseStatus;
}