summaryrefslogtreecommitdiff
path: root/src/mongo/db/index_builds_coordinator_mongod.cpp
diff options
context:
space:
mode:
authorCheahuychou Mao <cheahuychou.mao@mongodb.com>2019-12-06 16:30:41 +0000
committerevergreen <evergreen@mongodb.com>2019-12-06 16:30:41 +0000
commiteba76c558b3e7d784c146b51ced16d48b1d0efe7 (patch)
treeeb43d876af50dfd29a6596878f15ed9ab500a30b /src/mongo/db/index_builds_coordinator_mongod.cpp
parent13944bb3fedc8d91c02c56bb66bb5c76a0a558d0 (diff)
downloadmongo-eba76c558b3e7d784c146b51ced16d48b1d0efe7.tar.gz
SERVER-44719 Make createIndexes, dropIndexes, and collMod check shard versions
Diffstat (limited to 'src/mongo/db/index_builds_coordinator_mongod.cpp')
-rw-r--r--src/mongo/db/index_builds_coordinator_mongod.cpp16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/mongo/db/index_builds_coordinator_mongod.cpp b/src/mongo/db/index_builds_coordinator_mongod.cpp
index 41a5a2ea25a..36968811cc2 100644
--- a/src/mongo/db/index_builds_coordinator_mongod.cpp
+++ b/src/mongo/db/index_builds_coordinator_mongod.cpp
@@ -38,6 +38,7 @@
#include "mongo/db/db_raii.h"
#include "mongo/db/index_build_entry_helpers.h"
#include "mongo/db/operation_context.h"
+#include "mongo/db/s/operation_sharding_state.h"
#include "mongo/db/service_context.h"
#include "mongo/util/assert_util.h"
#include "mongo/util/fail_point.h"
@@ -139,6 +140,13 @@ IndexBuildsCoordinatorMongod::startIndexBuild(OperationContext* opCtx,
const auto deadline = opCtx->getDeadline();
const auto timeoutError = opCtx->getTimeoutError();
+ const NamespaceStringOrUUID nssOrUuid{dbName, collectionUUID};
+ const auto nss = CollectionCatalog::get(opCtx).resolveNamespaceStringOrUUID(opCtx, nssOrUuid);
+
+ const auto& oss = OperationShardingState::get(opCtx);
+ const auto shardVersion = oss.getShardVersion(nss);
+ const auto dbVersion = oss.getDbVersion(dbName);
+
// Task in thread pool should have similar CurOp representation to the caller so that it can be
// identified as a createIndexes operation.
LogicalOp logicalOp = LogicalOp::opInvalid;
@@ -165,6 +173,7 @@ IndexBuildsCoordinatorMongod::startIndexBuild(OperationContext* opCtx,
buildUUID,
collectionUUID,
dbName,
+ nss,
deadline,
indexBuildOptions,
logicalOp,
@@ -172,7 +181,9 @@ IndexBuildsCoordinatorMongod::startIndexBuild(OperationContext* opCtx,
replState,
startPromise = std::move(startPromise),
startTimestamp,
- timeoutError
+ timeoutError,
+ shardVersion,
+ dbVersion
](auto status) mutable noexcept {
// Clean up if we failed to schedule the task.
if (!status.isOK()) {
@@ -185,6 +196,9 @@ IndexBuildsCoordinatorMongod::startIndexBuild(OperationContext* opCtx,
auto opCtx = Client::getCurrent()->makeOperationContext();
opCtx->setDeadlineByDate(deadline, timeoutError);
+ auto& oss = OperationShardingState::get(opCtx.get());
+ oss.initializeClientRoutingVersions(nss, shardVersion, dbVersion);
+
{
stdx::unique_lock<Client> lk(*opCtx->getClient());
auto curOp = CurOp::get(opCtx.get());