diff options
author | Dan Pasette <dan@mongodb.com> | 2015-12-18 17:49:09 -0500 |
---|---|---|
committer | Dan Pasette <dan@mongodb.com> | 2015-12-18 17:49:09 -0500 |
commit | 39879fb9b856c170fc6884bc365a3be2632ef86b (patch) | |
tree | f5a678291ef528e4c0a7afe1b0ae379ef9f24ea0 | |
parent | 5a38be48f5c941bcebb1f12286c9427da796ea0b (diff) | |
download | mongo-39879fb9b856c170fc6884bc365a3be2632ef86b.tar.gz |
Revert "SERVER-21366 Periodically yield when applying migration deletions"
This reverts commit b306a90872fcf190462daaad1c3154d48c324ca9.
-rw-r--r-- | jstests/libs/chunk_manipulation_util.js | 10 | ||||
-rw-r--r-- | src/mongo/db/s/migration_destination_manager.cpp | 64 |
2 files changed, 23 insertions, 51 deletions
diff --git a/jstests/libs/chunk_manipulation_util.js b/jstests/libs/chunk_manipulation_util.js index 60037a46c04..b1e4d5a90e1 100644 --- a/jstests/libs/chunk_manipulation_util.js +++ b/jstests/libs/chunk_manipulation_util.js @@ -197,10 +197,8 @@ function configureMigrateFailPoint( shardConnection, stepNumber, mode ) { // Wait for moveChunk to reach a step (1 through 6). // function waitForMigrateStep( shardConnection, stepNumber ) { - var migrateThreadPrefix = 'migrateThread-'; - var searchStringPrefix = 'step ' + stepNumber; - - var admin = shardConnection.getDB('admin'); + var searchString = 'step ' + stepNumber, + admin = shardConnection.getDB( 'admin' ); assert( stepNumber >= 1); assert( stepNumber <= 5 ); @@ -216,8 +214,8 @@ function waitForMigrateStep( shardConnection, stepNumber ) { var in_progress = admin.currentOp(true).inprog; for ( var i = 0; i < in_progress.length; ++i ) { var op = in_progress[i]; - if (op.desc && op.desc.startsWith(migrateThreadPrefix)) { - return op.msg.startsWith(searchStringPrefix); + if ( op.desc && op.desc === 'migrateThread' ) { + return op.msg.startsWith( searchString ); } } diff --git a/src/mongo/db/s/migration_destination_manager.cpp b/src/mongo/db/s/migration_destination_manager.cpp index 053d4b09840..bf7a483d993 100644 --- a/src/mongo/db/s/migration_destination_manager.cpp +++ b/src/mongo/db/s/migration_destination_manager.cpp @@ -48,8 +48,8 @@ #include "mongo/db/dbhelpers.h" #include "mongo/db/namespace_string.h" #include "mongo/db/operation_context.h" +#include "mongo/db/operation_context_impl.h" #include "mongo/db/ops/delete.h" -#include "mongo/db/query/query_knobs.h" #include "mongo/db/range_deleter_service.h" #include "mongo/db/repl/repl_client_info.h" #include "mongo/db/repl/replication_coordinator_global.h" @@ -309,19 +309,17 @@ void MigrationDestinationManager::_migrateThread(std::string ns, std::string fromShard, OID epoch, WriteConcernOptions writeConcern) { - const std::string migrateThreadName(str::stream() << "migrateThread-" << ns); - Client::initThread(migrateThreadName.c_str()); + Client::initThread("migrateThread"); - Client* const client = &cc(); - auto txn = getGlobalServiceContext()->makeOperationContext(client); + OperationContextImpl txn; if (getGlobalAuthorizationManager()->isAuthEnabled()) { ShardedConnectionInfo::addHook(); - AuthorizationSession::get(txn->getClient())->grantInternalAuthorization(); + AuthorizationSession::get(txn.getClient())->grantInternalAuthorization(); } try { - _migrateDriver(txn.get(), ns, min, max, shardKeyPattern, fromShard, epoch, writeConcern); + _migrateDriver(&txn, ns, min, max, shardKeyPattern, fromShard, epoch, writeConcern); } catch (std::exception& e) { { stdx::lock_guard<stdx::mutex> sl(_mutex); @@ -337,18 +335,17 @@ void MigrationDestinationManager::_migrateThread(std::string ns, _errmsg = "UNKNOWN ERROR"; } - severe() << "migrate failed with unknown exception" << migrateLog; + error() << "migrate failed with unknown exception" << migrateLog; } if (getState() != DONE) { // Unprotect the range if needed/possible on unsuccessful TO migration - ScopedTransaction transaction(txn.get(), MODE_IX); - Lock::DBLock dbLock(txn->lockState(), nsToDatabaseSubstring(ns), MODE_IX); - Lock::CollectionLock collLock(txn->lockState(), ns, MODE_X); + ScopedTransaction transaction(&txn, MODE_IX); + Lock::DBLock dbLock(txn.lockState(), nsToDatabaseSubstring(ns), MODE_IX); + Lock::CollectionLock collLock(txn.lockState(), ns, MODE_X); string errMsg; - if (!ShardingState::get(txn.get()) - ->forgetPending(txn.get(), ns, min, max, epoch, &errMsg)) { + if (!ShardingState::get(&txn)->forgetPending(&txn, ns, min, max, epoch, &errMsg)) { warning() << errMsg; } } @@ -813,54 +810,31 @@ bool MigrationDestinationManager::_applyMigrateOp(OperationContext* txn, bool didAnything = false; if (xfer["deleted"].isABSONObj()) { - boost::optional<Helpers::RemoveSaver> removeSaver; - if (serverGlobalParams.moveParanoia) { - removeSaver.emplace("moveChunk", ns, "removedDuring"); - } - - boost::optional<ScopedTransaction> autoXact; - boost::optional<AutoGetCollection> autoColl; - - const int maxItersBeforeYield = - std::max(static_cast<int>(internalQueryExecYieldIterations), 1); - int opCounter = 0; + ScopedTransaction transaction(txn, MODE_IX); + Lock::DBLock dlk(txn->lockState(), nsToDatabaseSubstring(ns), MODE_IX); + Helpers::RemoveSaver rs("moveChunk", ns, "removedDuring"); BSONObjIterator i(xfer["deleted"].Obj()); while (i.more()) { - if (opCounter % maxItersBeforeYield == 0) { - autoXact.reset(); - autoColl.reset(); - autoXact.emplace(txn, MODE_IX); - autoColl.emplace(txn, NamespaceString(ns), MODE_X); - } - - // If the collection does not exist there won't be any documents to remove. This - // condition can only happen if deletions are happening for an empty chunk or in the - // unlikely event that someone manually deleted the collection. - if (!autoColl->getCollection()) { - break; - } + Lock::CollectionLock clk(txn->lockState(), ns, MODE_X); + OldClientContext ctx(txn, ns); BSONObj id = i.next().Obj(); - // Increment the counter before doing either the read or delete, so we yield the WT - // snapshot more aggressively - opCounter++; - // do not apply deletes if they do not belong to the chunk being migrated BSONObj fullObj; - if (Helpers::findById(txn, autoColl->getDb(), ns.c_str(), id, fullObj)) { + if (Helpers::findById(txn, ctx.db(), ns.c_str(), id, fullObj)) { if (!isInRange(fullObj, min, max, shardKeyPattern)) { continue; } } - if (removeSaver) { - removeSaver->goingToDelete(fullObj); + if (serverGlobalParams.moveParanoia) { + rs.goingToDelete(fullObj); } deleteObjects(txn, - autoColl->getCollection(), + ctx.db() ? ctx.db()->getCollection(ns) : nullptr, ns, id, PlanExecutor::YIELD_MANUAL, |