diff options
Diffstat (limited to 'src/mongo/s/commands/cluster_move_primary_cmd.cpp')
-rw-r--r-- | src/mongo/s/commands/cluster_move_primary_cmd.cpp | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/src/mongo/s/commands/cluster_move_primary_cmd.cpp b/src/mongo/s/commands/cluster_move_primary_cmd.cpp index 652c204c60e..dc192f1a6a6 100644 --- a/src/mongo/s/commands/cluster_move_primary_cmd.cpp +++ b/src/mongo/s/commands/cluster_move_primary_cmd.cpp @@ -101,7 +101,7 @@ public: return nsElt.str(); } - virtual bool run(OperationContext* txn, + virtual bool run(OperationContext* opCtx, const std::string& dbname_unused, BSONObj& cmdObj, int options, @@ -120,14 +120,14 @@ public: return false; } - auto const catalogClient = Grid::get(txn)->catalogClient(txn); - auto const catalogCache = Grid::get(txn)->catalogCache(); - auto const shardRegistry = Grid::get(txn)->shardRegistry(); + auto const catalogClient = Grid::get(opCtx)->catalogClient(opCtx); + auto const catalogCache = Grid::get(opCtx)->catalogCache(); + auto const shardRegistry = Grid::get(opCtx)->shardRegistry(); // Flush all cached information. This can't be perfect, but it's better than nothing. catalogCache->invalidate(dbname); - auto config = uassertStatusOK(catalogCache->getDatabase(txn, dbname)); + auto config = uassertStatusOK(catalogCache->getDatabase(opCtx, dbname)); const auto toElt = cmdObj["to"]; uassert(ErrorCodes::TypeMismatch, @@ -140,10 +140,10 @@ public: } const auto fromShard = - uassertStatusOK(shardRegistry->getShard(txn, config->getPrimaryId())); + uassertStatusOK(shardRegistry->getShard(opCtx, config->getPrimaryId())); const auto toShard = [&]() { - auto toShardStatus = shardRegistry->getShard(txn, to); + auto toShardStatus = shardRegistry->getShard(opCtx, to); if (!toShardStatus.isOK()) { const std::string msg( str::stream() << "Could not move database '" << dbname << "' to shard '" << to @@ -165,13 +165,13 @@ public: const std::string whyMessage(str::stream() << "Moving primary shard of " << dbname); auto scopedDistLock = uassertStatusOK(catalogClient->getDistLockManager()->lock( - txn, dbname + "-movePrimary", whyMessage, DistLockManager::kDefaultLockTimeout)); + opCtx, dbname + "-movePrimary", whyMessage, DistLockManager::kDefaultLockTimeout)); - const auto shardedColls = getAllShardedCollectionsForDb(txn, dbname); + const auto shardedColls = getAllShardedCollectionsForDb(opCtx, dbname); // Record start in changelog catalogClient->logChange( - txn, + opCtx, "movePrimary.start", dbname, _buildMoveLogEntry(dbname, fromShard->toString(), toShard->toString(), shardedColls), @@ -197,7 +197,7 @@ public: << bypassDocumentValidationCommandOption() << true << "writeConcern" - << txn->getWriteConcern().toBSON()), + << opCtx->getWriteConcern().toBSON()), cloneRes); toconn.done(); @@ -215,10 +215,10 @@ public: // Update the new primary in the config server metadata { - auto dbt = uassertStatusOK(catalogClient->getDatabase(txn, dbname)).value; + auto dbt = uassertStatusOK(catalogClient->getDatabase(opCtx, dbname)).value; dbt.setPrimary(toShard->getId()); - uassertStatusOK(catalogClient->updateDatabase(txn, dbname, dbt)); + uassertStatusOK(catalogClient->updateDatabase(opCtx, dbname, dbt)); } // Ensure the next attempt to retrieve the database or any of its collections will do a full @@ -236,7 +236,7 @@ public: try { BSONObj dropDBInfo; - fromconn->dropDatabase(dbname.c_str(), txn->getWriteConcern(), &dropDBInfo); + fromconn->dropDatabase(dbname.c_str(), opCtx->getWriteConcern(), &dropDBInfo); if (!hasWCError) { if (auto wcErrorElem = dropDBInfo["writeConcernError"]) { appendWriteConcernErrorToCmdResponse( @@ -269,7 +269,7 @@ public: << oldPrimary; BSONObj dropCollInfo; fromconn->dropCollection( - el.String(), txn->getWriteConcern(), &dropCollInfo); + el.String(), opCtx->getWriteConcern(), &dropCollInfo); if (!hasWCError) { if (auto wcErrorElem = dropCollInfo["writeConcernError"]) { appendWriteConcernErrorToCmdResponse( @@ -296,7 +296,7 @@ public: // Record finish in changelog catalogClient->logChange( - txn, + opCtx, "movePrimary", dbname, _buildMoveLogEntry(dbname, oldPrimary, toShard->toString(), shardedColls), |