diff options
Diffstat (limited to 'src/mongo/db/commands/drop_indexes.cpp')
-rw-r--r-- | src/mongo/db/commands/drop_indexes.cpp | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/src/mongo/db/commands/drop_indexes.cpp b/src/mongo/db/commands/drop_indexes.cpp index b3f2b73d21f..86082761cce 100644 --- a/src/mongo/db/commands/drop_indexes.cpp +++ b/src/mongo/db/commands/drop_indexes.cpp @@ -84,14 +84,14 @@ public: } CmdDropIndexes() : Command("dropIndexes", false, "deleteIndexes") {} - bool run(OperationContext* txn, + bool run(OperationContext* opCtx, const string& dbname, BSONObj& jsobj, int, string& errmsg, BSONObjBuilder& result) { const NamespaceString nss = parseNsCollectionRequired(dbname, jsobj); - return appendCommandStatus(result, dropIndexes(txn, nss, jsobj, &result)); + return appendCommandStatus(result, dropIndexes(opCtx, nss, jsobj, &result)); } } cmdDropIndexes; @@ -116,25 +116,25 @@ public: } CmdReIndex() : Command("reIndex") {} - bool run(OperationContext* txn, + bool run(OperationContext* opCtx, const string& dbname, BSONObj& jsobj, int, string& errmsg, BSONObjBuilder& result) { - DBDirectClient db(txn); + DBDirectClient db(opCtx); const NamespaceString toReIndexNs = parseNsCollectionRequired(dbname, jsobj); LOG(0) << "CMD: reIndex " << toReIndexNs; - ScopedTransaction transaction(txn, MODE_IX); - Lock::DBLock dbXLock(txn->lockState(), dbname, MODE_X); - OldClientContext ctx(txn, toReIndexNs.ns()); + ScopedTransaction transaction(opCtx, MODE_IX); + Lock::DBLock dbXLock(opCtx->lockState(), dbname, MODE_X); + OldClientContext ctx(opCtx, toReIndexNs.ns()); Collection* collection = ctx.db()->getCollection(toReIndexNs.ns()); if (!collection) { - if (ctx.db()->getViewCatalog()->lookup(txn, toReIndexNs.ns())) + if (ctx.db()->getViewCatalog()->lookup(opCtx, toReIndexNs.ns())) return appendCommandStatus( result, {ErrorCodes::CommandNotSupportedOnView, "can't re-index a view"}); else @@ -152,12 +152,12 @@ public: vector<BSONObj> all; { vector<string> indexNames; - collection->getCatalogEntry()->getAllIndexes(txn, &indexNames); + collection->getCatalogEntry()->getAllIndexes(opCtx, &indexNames); all.reserve(indexNames.size()); for (size_t i = 0; i < indexNames.size(); i++) { const string& name = indexNames[i]; - BSONObj spec = collection->getCatalogEntry()->getIndexSpec(txn, name); + BSONObj spec = collection->getCatalogEntry()->getIndexSpec(opCtx, name); { BSONObjBuilder bob; @@ -192,8 +192,8 @@ public: result.appendNumber("nIndexesWas", all.size()); { - WriteUnitOfWork wunit(txn); - Status s = collection->getIndexCatalog()->dropAllIndexes(txn, true); + WriteUnitOfWork wunit(opCtx); + Status s = collection->getIndexCatalog()->dropAllIndexes(opCtx, true); if (!s.isOK()) { errmsg = "dropIndexes failed"; return appendCommandStatus(result, s); @@ -201,7 +201,7 @@ public: wunit.commit(); } - MultiIndexBlock indexer(txn, collection); + MultiIndexBlock indexer(opCtx, collection); // do not want interruption as that will leave us without indexes. auto indexInfoObjs = indexer.init(all); @@ -215,7 +215,7 @@ public: } { - WriteUnitOfWork wunit(txn); + WriteUnitOfWork wunit(opCtx); indexer.commit(); wunit.commit(); } @@ -224,8 +224,8 @@ public: // This was also done when dropAllIndexes() committed, but we need to ensure that no one // tries to read in the intermediate state where all indexes are newer than the current // snapshot so are unable to be used. - auto replCoord = repl::ReplicationCoordinator::get(txn); - auto snapshotName = replCoord->reserveSnapshotName(txn); + auto replCoord = repl::ReplicationCoordinator::get(opCtx); + auto snapshotName = replCoord->reserveSnapshotName(opCtx); replCoord->forceSnapshotCreation(); // Ensures a newer snapshot gets created even if idle. collection->setMinimumVisibleSnapshot(snapshotName); |