summaryrefslogtreecommitdiff
path: root/src/mongo/db
diff options
context:
space:
mode:
authorKaloian Manassiev <kaloian.manassiev@mongodb.com>2014-10-10 08:54:46 -0400
committerKaloian Manassiev <kaloian.manassiev@mongodb.com>2014-10-10 11:49:21 -0400
commitc868a14dfa6d1a926f38795a1273a7146cef6e77 (patch)
tree386d352dbb9b5bb46cd172246a686346dae3e6cf /src/mongo/db
parentfd09fb0f37c24c99d6c6b605702d580ace6a4250 (diff)
downloadmongo-c868a14dfa6d1a926f38795a1273a7146cef6e77.tar.gz
SERVER-14425 Move LockManager out of the newlm namespace
Diffstat (limited to 'src/mongo/db')
-rw-r--r--src/mongo/db/auth/auth_index_d.cpp2
-rw-r--r--src/mongo/db/client.cpp18
-rw-r--r--src/mongo/db/client.h2
-rw-r--r--src/mongo/db/cloner.cpp2
-rw-r--r--src/mongo/db/commands/apply_ops.cpp2
-rw-r--r--src/mongo/db/commands/clone.cpp2
-rw-r--r--src/mongo/db/commands/collection_to_capped.cpp2
-rw-r--r--src/mongo/db/commands/compact.cpp2
-rw-r--r--src/mongo/db/commands/copydb.cpp2
-rw-r--r--src/mongo/db/commands/cpuprofile.cpp4
-rw-r--r--src/mongo/db/commands/create_indexes.cpp2
-rw-r--r--src/mongo/db/commands/dbhash.cpp2
-rw-r--r--src/mongo/db/commands/drop_indexes.cpp4
-rw-r--r--src/mongo/db/commands/find_and_modify.cpp2
-rw-r--r--src/mongo/db/commands/list_collections.cpp2
-rw-r--r--src/mongo/db/commands/mr.cpp6
-rw-r--r--src/mongo/db/commands/test_commands.cpp2
-rw-r--r--src/mongo/db/commands/write_commands/batch_executor.cpp10
-rw-r--r--src/mongo/db/commands/write_commands/write_commands.cpp4
-rw-r--r--src/mongo/db/concurrency/d_concurrency.cpp36
-rw-r--r--src/mongo/db/concurrency/d_concurrency.h18
-rw-r--r--src/mongo/db/concurrency/d_concurrency_test.cpp29
-rw-r--r--src/mongo/db/concurrency/lock_mgr_new.cpp2
-rw-r--r--src/mongo/db/concurrency/lock_mgr_new.h7
-rw-r--r--src/mongo/db/concurrency/lock_mgr_new_test.cpp2
-rw-r--r--src/mongo/db/concurrency/lock_mgr_test_help.h2
-rw-r--r--src/mongo/db/concurrency/lock_state.cpp92
-rw-r--r--src/mongo/db/concurrency/lock_state.h9
-rw-r--r--src/mongo/db/concurrency/lock_state_test.cpp6
-rw-r--r--src/mongo/db/concurrency/locker.h22
-rw-r--r--src/mongo/db/concurrency/resource_id.h6
-rw-r--r--src/mongo/db/dbcommands.cpp12
-rw-r--r--src/mongo/db/exec/stagedebug_cmd.cpp2
-rw-r--r--src/mongo/db/index_builder.cpp2
-rw-r--r--src/mongo/db/index_rebuilder.cpp4
-rw-r--r--src/mongo/db/instance.cpp16
-rw-r--r--src/mongo/db/introspect.cpp2
-rw-r--r--src/mongo/db/operation_context_impl.cpp2
-rw-r--r--src/mongo/db/ops/update_executor.cpp2
-rw-r--r--src/mongo/db/prefetch.cpp2
-rw-r--r--src/mongo/db/repl/master_slave.cpp2
-rw-r--r--src/mongo/db/repl/minvalid.cpp6
-rw-r--r--src/mongo/db/repl/oplog.cpp6
-rw-r--r--src/mongo/db/repl/repl_coordinator_external_state_impl.cpp4
-rw-r--r--src/mongo/db/repl/rs_initialsync.cpp4
-rw-r--r--src/mongo/db/repl/sync_source_feedback.cpp2
-rw-r--r--src/mongo/db/repl/sync_tail.cpp6
-rw-r--r--src/mongo/db/storage/mmap_v1/dur.cpp4
48 files changed, 182 insertions, 199 deletions
diff --git a/src/mongo/db/auth/auth_index_d.cpp b/src/mongo/db/auth/auth_index_d.cpp
index 20f2bd2eb5d..7c223c5ce0a 100644
--- a/src/mongo/db/auth/auth_index_d.cpp
+++ b/src/mongo/db/auth/auth_index_d.cpp
@@ -84,7 +84,7 @@ namespace {
const NamespaceString systemUsers("admin", "system.users");
// Make sure the old unique index from v2.4 on system.users doesn't exist.
- AutoGetDb autoDb(txn, systemUsers.db(), newlm::MODE_X);
+ AutoGetDb autoDb(txn, systemUsers.db(), MODE_X);
if (!autoDb.getDb()) {
return;
}
diff --git a/src/mongo/db/client.cpp b/src/mongo/db/client.cpp
index 917003e4916..49b951e87c1 100644
--- a/src/mongo/db/client.cpp
+++ b/src/mongo/db/client.cpp
@@ -188,7 +188,7 @@ namespace mongo {
}
- AutoGetDb::AutoGetDb(OperationContext* txn, const StringData& ns, newlm::LockMode mode)
+ AutoGetDb::AutoGetDb(OperationContext* txn, const StringData& ns, LockMode mode)
: _dbLock(txn->lockState(), ns, mode),
_db(dbHolder().get(txn, ns)) {
@@ -199,7 +199,7 @@ namespace mongo {
const std::string& ns)
: _txn(txn),
_nss(ns),
- _dbLock(_txn->lockState(), _nss.db(), newlm::MODE_IS),
+ _dbLock(_txn->lockState(), _nss.db(), MODE_IS),
_db(NULL),
_coll(NULL) {
@@ -210,7 +210,7 @@ namespace mongo {
const NamespaceString& nss)
: _txn(txn),
_nss(nss),
- _dbLock(_txn->lockState(), _nss.db(), newlm::MODE_IS),
+ _dbLock(_txn->lockState(), _nss.db(), MODE_IS),
_db(NULL),
_coll(NULL) {
@@ -226,10 +226,10 @@ namespace mongo {
// Lock both the DB and the collection (DB is locked in the constructor), because this is
// necessary in order to to shard version checking.
- const newlm::ResourceId resId(newlm::RESOURCE_COLLECTION, _nss);
- const newlm::LockMode collLockMode = supportsDocLocking() ? newlm::MODE_IS : newlm::MODE_S;
+ const ResourceId resId(RESOURCE_COLLECTION, _nss);
+ const LockMode collLockMode = supportsDocLocking() ? MODE_IS : MODE_S;
- invariant(newlm::LOCK_OK == _txn->lockState()->lock(resId, collLockMode));
+ invariant(LOCK_OK == _txn->lockState()->lock(resId, collLockMode));
// Shard version check needs to be performed under the collection lock
ensureShardVersionOKOrThrow(_nss);
@@ -248,7 +248,7 @@ namespace mongo {
AutoGetCollectionForRead::~AutoGetCollectionForRead() {
// If the database is NULL, we would never have tried to lock the collection resource
if (_db) {
- const newlm::ResourceId resId(newlm::RESOURCE_COLLECTION, _nss);
+ const ResourceId resId(RESOURCE_COLLECTION, _nss);
_txn->lockState()->unlock(resId);
}
@@ -260,8 +260,8 @@ namespace mongo {
Client::WriteContext::WriteContext(OperationContext* opCtx, const std::string& ns)
: _txn(opCtx),
_nss(ns),
- _dblk(opCtx->lockState(), _nss.db(), newlm::MODE_IX),
- _collk(opCtx->lockState(), ns, newlm::MODE_IX),
+ _dblk(opCtx->lockState(), _nss.db(), MODE_IX),
+ _collk(opCtx->lockState(), ns, MODE_IX),
_wunit(opCtx),
_c(opCtx, ns) { }
diff --git a/src/mongo/db/client.h b/src/mongo/db/client.h
index 99957f6359e..8f82c5d67d3 100644
--- a/src/mongo/db/client.h
+++ b/src/mongo/db/client.h
@@ -218,7 +218,7 @@ namespace mongo {
class AutoGetDb {
MONGO_DISALLOW_COPYING(AutoGetDb);
public:
- AutoGetDb(OperationContext* txn, const StringData& ns, newlm::LockMode mode);
+ AutoGetDb(OperationContext* txn, const StringData& ns, LockMode mode);
Database* getDb() const {
return _db;
diff --git a/src/mongo/db/cloner.cpp b/src/mongo/db/cloner.cpp
index 109c0598711..985ce76e473 100644
--- a/src/mongo/db/cloner.cpp
+++ b/src/mongo/db/cloner.cpp
@@ -308,7 +308,7 @@ namespace mongo {
const NamespaceString nss(ns);
const string dbname = nss.db().toString();
- Lock::DBLock dbWrite(txn->lockState(), dbname, newlm::MODE_X);
+ Lock::DBLock dbWrite(txn->lockState(), dbname, MODE_X);
Database* db = dbHolder().openDb(txn, dbname);
diff --git a/src/mongo/db/commands/apply_ops.cpp b/src/mongo/db/commands/apply_ops.cpp
index cc760412120..4b2858d9505 100644
--- a/src/mongo/db/commands/apply_ops.cpp
+++ b/src/mongo/db/commands/apply_ops.cpp
@@ -137,7 +137,7 @@ namespace mongo {
// We do not have a wrapping WriteUnitOfWork so it is possible for a journal
// commit to happen with a subset of ops applied.
// TODO figure out what to do about this.
- Lock::DBLock lk(txn->lockState(), nsToDatabaseSubstring(ns), newlm::MODE_X);
+ Lock::DBLock lk(txn->lockState(), nsToDatabaseSubstring(ns), MODE_X);
invariant(txn->lockState()->isRecursive());
Client::Context ctx(txn, ns);
diff --git a/src/mongo/db/commands/clone.cpp b/src/mongo/db/commands/clone.cpp
index 0b73001e559..44270a6596d 100644
--- a/src/mongo/db/commands/clone.cpp
+++ b/src/mongo/db/commands/clone.cpp
@@ -115,7 +115,7 @@ namespace mongo {
set<string> clonedColls;
- Lock::DBLock dbXLock(txn->lockState(), dbname, newlm::MODE_X);
+ Lock::DBLock dbXLock(txn->lockState(), dbname, MODE_X);
Cloner cloner;
bool rval = cloner.go(txn, dbname, from, opts, &clonedColls, errmsg);
diff --git a/src/mongo/db/commands/collection_to_capped.cpp b/src/mongo/db/commands/collection_to_capped.cpp
index 24439e82b9b..6be8e0d7cd5 100644
--- a/src/mongo/db/commands/collection_to_capped.cpp
+++ b/src/mongo/db/commands/collection_to_capped.cpp
@@ -161,7 +161,7 @@ namespace mongo {
return false;
}
- Lock::DBLock dbXLock(txn->lockState(), dbname, newlm::MODE_X);
+ Lock::DBLock dbXLock(txn->lockState(), dbname, MODE_X);
Client::Context ctx(txn, dbname);
Status status = cloneCollectionAsCapped( txn, ctx.db(), from, to, size, temp, true );
diff --git a/src/mongo/db/commands/compact.cpp b/src/mongo/db/commands/compact.cpp
index 8ffac0bff38..d2703c560f4 100644
--- a/src/mongo/db/commands/compact.cpp
+++ b/src/mongo/db/commands/compact.cpp
@@ -144,7 +144,7 @@ namespace mongo {
compactOptions.validateDocuments = cmdObj["validate"].trueValue();
- Lock::DBLock lk(txn->lockState(), db, newlm::MODE_X);
+ Lock::DBLock lk(txn->lockState(), db, MODE_X);
BackgroundOperation::assertNoBgOpInProgForNs(ns.ns());
Client::Context ctx(txn, ns);
diff --git a/src/mongo/db/commands/copydb.cpp b/src/mongo/db/commands/copydb.cpp
index 58f733e02b0..469e0cd0a59 100644
--- a/src/mongo/db/commands/copydb.cpp
+++ b/src/mongo/db/commands/copydb.cpp
@@ -188,7 +188,7 @@ namespace mongo {
return cloner.go(txn, todb, fromhost, cloneOptions, NULL, errmsg);
}
- Lock::DBLock lk (txn->lockState(), todb, newlm::MODE_X);
+ Lock::DBLock lk (txn->lockState(), todb, MODE_X);
return cloner.go(txn, todb, fromhost, cloneOptions, NULL, errmsg);
}
diff --git a/src/mongo/db/commands/cpuprofile.cpp b/src/mongo/db/commands/cpuprofile.cpp
index b1c81ca3584..d25b7c034cb 100644
--- a/src/mongo/db/commands/cpuprofile.cpp
+++ b/src/mongo/db/commands/cpuprofile.cpp
@@ -133,7 +133,7 @@ namespace mongo {
std::string &errmsg,
BSONObjBuilder &result,
bool fromRepl ) {
- Lock::DBLock dbXLock(txn->lockState(), db, newlm::MODE_X);
+ Lock::DBLock dbXLock(txn->lockState(), db, MODE_X);
// The lock here is just to prevent concurrency, nothing will write.
Client::Context ctx(txn, db);
@@ -152,7 +152,7 @@ namespace mongo {
std::string &errmsg,
BSONObjBuilder &result,
bool fromRepl ) {
- Lock::DBLock dbXLock(txn->lockState(), db, newlm::MODE_X);
+ Lock::DBLock dbXLock(txn->lockState(), db, MODE_X);
WriteUnitOfWork wunit(txn);
Client::Context ctx(txn, db);
diff --git a/src/mongo/db/commands/create_indexes.cpp b/src/mongo/db/commands/create_indexes.cpp
index 43ff03f26e4..c978b5ec046 100644
--- a/src/mongo/db/commands/create_indexes.cpp
+++ b/src/mongo/db/commands/create_indexes.cpp
@@ -134,7 +134,7 @@ namespace mongo {
// now we know we have to create index(es)
// Note: createIndexes command does not currently respect shard versioning.
- Lock::DBLock lk(txn->lockState(), ns.db(), newlm::MODE_X);
+ Lock::DBLock lk(txn->lockState(), ns.db(), MODE_X);
Client::Context ctx(txn, ns.ns(), false /* doVersion */ );
Database* db = ctx.db();
diff --git a/src/mongo/db/commands/dbhash.cpp b/src/mongo/db/commands/dbhash.cpp
index 596675d1ef6..2eabb57610e 100644
--- a/src/mongo/db/commands/dbhash.cpp
+++ b/src/mongo/db/commands/dbhash.cpp
@@ -149,7 +149,7 @@ namespace mongo {
// We lock the entire database in S-mode in order to ensure that the contents will not
// change for the snapshot.
- AutoGetDb autoDb(txn, ns, newlm::MODE_S);
+ AutoGetDb autoDb(txn, ns, MODE_S);
Database* db = autoDb.getDb();
if (db) {
db->getDatabaseCatalogEntry()->getCollectionNamespaces(&colls);
diff --git a/src/mongo/db/commands/drop_indexes.cpp b/src/mongo/db/commands/drop_indexes.cpp
index 937039070a4..ff2f975b5ef 100644
--- a/src/mongo/db/commands/drop_indexes.cpp
+++ b/src/mongo/db/commands/drop_indexes.cpp
@@ -104,7 +104,7 @@ namespace mongo {
CmdDropIndexes() : Command("dropIndexes", false, "deleteIndexes") { }
bool run(OperationContext* txn, const string& dbname, BSONObj& jsobj, int, string& errmsg, BSONObjBuilder& anObjBuilder, bool fromRepl) {
- Lock::DBLock dbXLock(txn->lockState(), dbname, newlm::MODE_X);
+ Lock::DBLock dbXLock(txn->lockState(), dbname, MODE_X);
WriteUnitOfWork wunit(txn);
bool ok = wrappedRun(txn, dbname, jsobj, errmsg, anObjBuilder);
if (!ok) {
@@ -240,7 +240,7 @@ namespace mongo {
LOG(0) << "CMD: reIndex " << toDeleteNs << endl;
- Lock::DBLock dbXLock(txn->lockState(), dbname, newlm::MODE_X);
+ Lock::DBLock dbXLock(txn->lockState(), dbname, MODE_X);
Client::Context ctx(txn, toDeleteNs);
Collection* collection = ctx.db()->getCollection( txn, toDeleteNs );
diff --git a/src/mongo/db/commands/find_and_modify.cpp b/src/mongo/db/commands/find_and_modify.cpp
index e8b308bbfdd..1298767fd9f 100644
--- a/src/mongo/db/commands/find_and_modify.cpp
+++ b/src/mongo/db/commands/find_and_modify.cpp
@@ -329,7 +329,7 @@ namespace mongo {
}
}
- Lock::DBLock dbXLock(txn->lockState(), dbname, newlm::MODE_X);
+ Lock::DBLock dbXLock(txn->lockState(), dbname, MODE_X);
WriteUnitOfWork wunit(txn);
Client::Context ctx(txn, ns);
diff --git a/src/mongo/db/commands/list_collections.cpp b/src/mongo/db/commands/list_collections.cpp
index e00872f983e..87f58770fc8 100644
--- a/src/mongo/db/commands/list_collections.cpp
+++ b/src/mongo/db/commands/list_collections.cpp
@@ -67,7 +67,7 @@ namespace mongo {
BSONObjBuilder& result,
bool /*fromRepl*/) {
- AutoGetDb autoDb(txn, dbname, newlm::MODE_S);
+ AutoGetDb autoDb(txn, dbname, MODE_S);
const Database* d = autoDb.getDb();
const DatabaseCatalogEntry* dbEntry = NULL;
diff --git a/src/mongo/db/commands/mr.cpp b/src/mongo/db/commands/mr.cpp
index 0e88bc4e2a4..fe76552c8e4 100644
--- a/src/mongo/db/commands/mr.cpp
+++ b/src/mongo/db/commands/mr.cpp
@@ -334,7 +334,7 @@ namespace mongo {
// harmless, this would lead to a scary looking warning on the secondaries.
Lock::DBLock lk(_txn->lockState(),
nsToDatabaseSubstring(_config.incLong),
- newlm::MODE_X);
+ MODE_X);
if (Database* db = dbHolder().get(_txn, _config.incLong)) {
WriteUnitOfWork wunit(_txn);
db->dropCollection(_txn, _config.incLong);
@@ -594,7 +594,7 @@ namespace mongo {
while (cursor->more()) {
Lock::DBLock lock(_txn->lockState(),
nsToDatabaseSubstring(_config.outputOptions.finalNamespace),
- newlm::MODE_X);
+ MODE_X);
WriteUnitOfWork wunit(_txn);
BSONObj o = cursor->nextSafe();
Helpers::upsert( _txn, _config.outputOptions.finalNamespace , o );
@@ -1113,7 +1113,7 @@ namespace mongo {
Lock::DBLock kl(_txn->lockState(),
nsToDatabaseSubstring(_config.incLong),
- newlm::MODE_X);
+ MODE_X);
WriteUnitOfWork wunit(_txn);
for ( InMemory::iterator i=_temp->begin(); i!=_temp->end(); i++ ) {
diff --git a/src/mongo/db/commands/test_commands.cpp b/src/mongo/db/commands/test_commands.cpp
index 9121971efb1..16f8fae04f0 100644
--- a/src/mongo/db/commands/test_commands.cpp
+++ b/src/mongo/db/commands/test_commands.cpp
@@ -64,7 +64,7 @@ namespace mongo {
string ns = dbname + "." + coll;
BSONObj obj = cmdObj[ "obj" ].embeddedObjectUserCheck();
- Lock::DBLock lk(txn->lockState(), dbname, newlm::MODE_X);
+ Lock::DBLock lk(txn->lockState(), dbname, MODE_X);
WriteUnitOfWork wunit(txn);
Client::Context ctx(txn, ns );
Database* db = ctx.db();
diff --git a/src/mongo/db/commands/write_commands/batch_executor.cpp b/src/mongo/db/commands/write_commands/batch_executor.cpp
index e59c6fbca69..b71978dc5a6 100644
--- a/src/mongo/db/commands/write_commands/batch_executor.cpp
+++ b/src/mongo/db/commands/write_commands/batch_executor.cpp
@@ -928,10 +928,10 @@ namespace mongo {
invariant(!_context.get());
_writeLock.reset(new Lock::DBLock(txn->lockState(),
nsToDatabase(request->getNS()),
- intentLock ? newlm::MODE_IX : newlm::MODE_X));
+ intentLock ? MODE_IX : MODE_X));
_collLock.reset(new Lock::CollectionLock(txn->lockState(),
request->getNS(),
- intentLock ? newlm::MODE_IX : newlm::MODE_X));
+ intentLock ? MODE_IX : MODE_X));
if (!checkIsMasterForDatabase(request->getNS(), result)) {
return false;
}
@@ -1144,10 +1144,10 @@ namespace mongo {
}
///////////////////////////////////////////
- Lock::DBLock dbLock(txn->lockState(), nsString.db(), newlm::MODE_IX);
+ Lock::DBLock dbLock(txn->lockState(), nsString.db(), MODE_IX);
Lock::CollectionLock colLock(txn->lockState(),
nsString.ns(),
- isMulti ? newlm::MODE_X : newlm::MODE_IX);
+ isMulti ? MODE_X : MODE_IX);
///////////////////////////////////////////
if (!checkShardVersion(txn, &shardingState, *updateItem.getRequest(), result))
@@ -1202,7 +1202,7 @@ namespace mongo {
}
///////////////////////////////////////////
- Lock::DBLock writeLock(txn->lockState(), nss.db(), newlm::MODE_X);
+ Lock::DBLock writeLock(txn->lockState(), nss.db(), MODE_X);
///////////////////////////////////////////
// Check version once we're locked
diff --git a/src/mongo/db/commands/write_commands/write_commands.cpp b/src/mongo/db/commands/write_commands/write_commands.cpp
index 5ec2bd98aa9..6adf097dba2 100644
--- a/src/mongo/db/commands/write_commands/write_commands.cpp
+++ b/src/mongo/db/commands/write_commands/write_commands.cpp
@@ -211,7 +211,7 @@ namespace mongo {
// Explains of write commands are read-only, but we take an exclusive lock so
// that timing info is more accurate.
- Lock::DBLock dlk(txn->lockState(), nsString.db(), newlm::MODE_X);
+ Lock::DBLock dlk(txn->lockState(), nsString.db(), MODE_X);
Client::Context ctx(txn, nsString);
Status prepInLockStatus = updateExecutor.prepareInLock(ctx.db());
@@ -246,7 +246,7 @@ namespace mongo {
// Explains of write commands are read-only, but we take a write lock so that timing
// info is more accurate.
- Lock::DBLock dlk(txn->lockState(), nsString.db(), newlm::MODE_X);
+ Lock::DBLock dlk(txn->lockState(), nsString.db(), MODE_X);
Client::Context ctx(txn, nsString);
Status prepInLockStatus = deleteExecutor.prepareInLock(ctx.db());
diff --git a/src/mongo/db/concurrency/d_concurrency.cpp b/src/mongo/db/concurrency/d_concurrency.cpp
index f510513fe5f..a93a28b33d1 100644
--- a/src/mongo/db/concurrency/d_concurrency.cpp
+++ b/src/mongo/db/concurrency/d_concurrency.cpp
@@ -197,7 +197,7 @@ namespace mongo {
invariant(!_lockState->isLocked());
TrackLockAcquireTime a('W');
- _lockState->lockGlobal(newlm::MODE_X);
+ _lockState->lockGlobal(MODE_X);
resetTime();
}
@@ -206,8 +206,8 @@ namespace mongo {
TrackLockAcquireTime a('W');
- newlm::LockResult result = _lockState->lockGlobal(newlm::MODE_X, timeoutms);
- if (result == newlm::LOCK_TIMEOUT) {
+ LockResult result = _lockState->lockGlobal(MODE_X, timeoutms);
+ if (result == LOCK_TIMEOUT) {
throw DBTryLockTimeoutException();
}
@@ -227,8 +227,8 @@ namespace mongo {
TrackLockAcquireTime a('R');
- newlm::LockResult result = _lockState->lockGlobal(newlm::MODE_S, timeoutms);
- if (result == newlm::LOCK_TIMEOUT) {
+ LockResult result = _lockState->lockGlobal(MODE_S, timeoutms);
+ if (result == LOCK_TIMEOUT) {
throw DBTryLockTimeoutException();
}
@@ -240,9 +240,9 @@ namespace mongo {
recordTime();
}
- Lock::DBLock::DBLock(Locker* lockState, const StringData& db, const newlm::LockMode mode)
- : ScopedLock(lockState, mode == newlm::MODE_S || mode == newlm::MODE_IS ? 'r' : 'w'),
- _id(newlm::RESOURCE_DATABASE, db),
+ Lock::DBLock::DBLock(Locker* lockState, const StringData& db, const LockMode mode)
+ : ScopedLock(lockState, mode == MODE_S || mode == MODE_IS ? 'r' : 'w'),
+ _id(RESOURCE_DATABASE, db),
_mode(mode) {
dassert(!db.empty());
dassert(!nsIsFull(db));
@@ -254,16 +254,16 @@ namespace mongo {
}
void Lock::DBLock::lockDB() {
- const bool isRead = (_mode == newlm::MODE_S || _mode == newlm::MODE_IS);
+ const bool isRead = (_mode == MODE_S || _mode == MODE_IS);
TrackLockAcquireTime a(isRead ? 'r' : 'w');
- _lockState->lockGlobal(isRead ? newlm::MODE_IS : newlm::MODE_IX);
+ _lockState->lockGlobal(isRead ? MODE_IS : MODE_IX);
if (supportsDocLocking()) {
// SERVER-14668: Make this branch unconditional when MMAPv1 has coll. locking
_lockState->lock(_id, _mode);
}
else {
- _lockState->lock(_id, isRead ? newlm::MODE_S : newlm::MODE_X);
+ _lockState->lock(_id, isRead ? MODE_S : MODE_X);
}
resetTime();
@@ -280,19 +280,19 @@ namespace mongo {
Lock::CollectionLock::CollectionLock(Locker* lockState,
const StringData& ns,
- newlm::LockMode mode)
- : _id(newlm::RESOURCE_COLLECTION, ns),
+ LockMode mode)
+ : _id(RESOURCE_COLLECTION, ns),
_lockState(lockState) {
- const bool isRead = (mode == newlm::MODE_S || mode == newlm::MODE_IS);
+ const bool isRead = (mode == MODE_S || mode == MODE_IS);
dassert(!ns.empty());
dassert(nsIsFull(ns));
- dassert(_lockState->isLockHeldForMode(newlm::ResourceId(newlm::RESOURCE_DATABASE,
+ dassert(_lockState->isLockHeldForMode(ResourceId(RESOURCE_DATABASE,
nsToDatabaseSubstring(ns)),
- isRead ? newlm::MODE_IS : newlm::MODE_IX));
+ isRead ? MODE_IS : MODE_IX));
if (supportsDocLocking()) {
_lockState->lock(_id, mode);
// SERVER-14668: add when MMAPv1 ready for collection-level locking
- // else { _lockState->lock(_id, isRead ? newlm::MODE_S : newlm::MODE_X); }
+ // else { _lockState->lock(_id, isRead ? MODE_S : MODE_X); }
invariant(isRead || !isRead); // artificial use to silence warning.
}
}
@@ -305,7 +305,7 @@ namespace mongo {
}
Lock::DBRead::DBRead(Locker* lockState, const StringData& dbOrNs) :
- DBLock(lockState, nsToDatabaseSubstring(dbOrNs), newlm::MODE_S) { }
+ DBLock(lockState, nsToDatabaseSubstring(dbOrNs), MODE_S) { }
writelocktry::writelocktry(Locker* lockState, int tryms) :
_got( false ),
diff --git a/src/mongo/db/concurrency/d_concurrency.h b/src/mongo/db/concurrency/d_concurrency.h
index a55eaa077f3..185662cb6da 100644
--- a/src/mongo/db/concurrency/d_concurrency.h
+++ b/src/mongo/db/concurrency/d_concurrency.h
@@ -128,7 +128,7 @@ namespace mongo {
*
* Allows exclusive write access to all databases and collections, blocking all other
* access. Allows further (recursive) acquisition of the global lock in any mode,
- * see newlm::LockMode.
+ * see LockMode.
*/
class GlobalWrite : public ScopedLock {
protected:
@@ -145,7 +145,7 @@ namespace mongo {
*
* Allows concurrent read access to all databases and collections, blocking any writers.
* Allows further (recursive) acquisition of the global lock in shared (S) or intent-shared
- * (IS) mode, see newlm::LockMode.
+ * (IS) mode, see LockMode.
*/
class GlobalRead : public ScopedLock {
public:
@@ -157,7 +157,7 @@ namespace mongo {
/**
* Database lock with support for collection- and document-level locking
*
- * This lock supports four modes (see newlm::Lock_Mode):
+ * This lock supports four modes (see Lock_Mode):
* MODE_IS: concurrent database access, requiring further collection read locks
* MODE_IX: concurrent database access, requiring further collection read or write locks
* MODE_S: shared read access to the database, blocking any writers
@@ -170,15 +170,15 @@ namespace mongo {
*/
class DBLock : public ScopedLock {
public:
- DBLock(Locker* lockState, const StringData& db, const newlm::LockMode mode);
+ DBLock(Locker* lockState, const StringData& db, const LockMode mode);
virtual ~DBLock();
private:
void lockDB();
void unlockDB();
- const newlm::ResourceId _id;
- const newlm::LockMode _mode;
+ const ResourceId _id;
+ const LockMode _mode;
protected:
// Still need to override these for ScopedLock::tempRelease() and relock().
@@ -190,7 +190,7 @@ namespace mongo {
/**
* Collection lock with support for document-level locking
*
- * This lock supports four modes (see newlm::Lock_Mode):
+ * This lock supports four modes (see Lock_Mode):
* MODE_IS: concurrent collection access, requiring document level locking read locks
* MODE_IX: concurrent collection access, requiring document level read or write locks
* MODE_S: shared read access to the collection, blocking any writers
@@ -203,10 +203,10 @@ namespace mongo {
*/
class CollectionLock : boost::noncopyable {
public:
- CollectionLock (Locker* lockState, const StringData& ns, const newlm::LockMode);
+ CollectionLock (Locker* lockState, const StringData& ns, const LockMode);
virtual ~CollectionLock();
private:
- const newlm::ResourceId _id;
+ const ResourceId _id;
Locker* _lockState;
};
diff --git a/src/mongo/db/concurrency/d_concurrency_test.cpp b/src/mongo/db/concurrency/d_concurrency_test.cpp
index ddc59b17bd7..f930529fcbe 100644
--- a/src/mongo/db/concurrency/d_concurrency_test.cpp
+++ b/src/mongo/db/concurrency/d_concurrency_test.cpp
@@ -92,18 +92,19 @@ namespace mongo {
TEST(DConcurrency, readlocktryTimeoutDueToFlushLock) {
LockState ls;
- newlm::AutoAcquireFlushLockForMMAPV1Commit autoFlushLock(&ls);
+ AutoAcquireFlushLockForMMAPV1Commit autoFlushLock(&ls);
{
LockState lsTry;
readlocktry lockTry(&lsTry, 1);
+
ASSERT(!lockTry.got());
}
}
TEST(DConcurrency, writelocktryTimeoutDueToFlushLock) {
LockState ls;
- newlm::AutoAcquireFlushLockForMMAPV1Commit autoFlushLock(&ls);
+ AutoAcquireFlushLockForMMAPV1Commit autoFlushLock(&ls);
{
LockState lsTry;
@@ -129,24 +130,24 @@ namespace mongo {
Lock::DBRead dbRead(&ls, "db");
- const newlm::ResourceId resIdDb(newlm::RESOURCE_DATABASE, string("db"));
- ASSERT(ls.getLockMode(resIdDb) == newlm::MODE_S);
+ const ResourceId resIdDb(RESOURCE_DATABASE, string("db"));
+ ASSERT(ls.getLockMode(resIdDb) == MODE_S);
}
TEST(DConcurrency, DBLockTakesX) {
LockState ls;
- Lock::DBLock dbWrite(&ls, "db", newlm::MODE_X);
+ Lock::DBLock dbWrite(&ls, "db", MODE_X);
- const newlm::ResourceId resIdDb(newlm::RESOURCE_DATABASE, string("db"));
- ASSERT(ls.getLockMode(resIdDb) == newlm::MODE_X);
+ const ResourceId resIdDb(RESOURCE_DATABASE, string("db"));
+ ASSERT(ls.getLockMode(resIdDb) == MODE_X);
}
TEST(DConcurrency, MultipleWriteDBLocksOnSameThread) {
LockState ls;
- Lock::DBLock r1(&ls, "db1", newlm::MODE_X);
- Lock::DBLock r2(&ls, "db1", newlm::MODE_X);
+ Lock::DBLock r1(&ls, "db1", MODE_X);
+ Lock::DBLock r2(&ls, "db1", MODE_X);
ASSERT(ls.isWriteLocked("db1"));
}
@@ -154,7 +155,7 @@ namespace mongo {
TEST(DConcurrency, MultipleConflictingDBLocksOnSameThread) {
LockState ls;
- Lock::DBLock r1(&ls, "db1", newlm::MODE_X);
+ Lock::DBLock r1(&ls, "db1", MODE_X);
Lock::DBRead r2(&ls, "db1");
ASSERT(ls.isWriteLocked("db1"));
@@ -163,12 +164,12 @@ namespace mongo {
TEST(DConcurrenty, IntentCollectionLock) {
LockState ls;
const std::string ns("db1.coll");
- const newlm::ResourceId id(newlm::RESOURCE_COLLECTION, ns);
- Lock::DBLock r1(&ls, "db1", newlm::MODE_X);
+ const ResourceId id(RESOURCE_COLLECTION, ns);
+ Lock::DBLock r1(&ls, "db1", MODE_X);
{
- Lock::CollectionLock r2(&ls, ns, newlm::MODE_S);
+ Lock::CollectionLock r2(&ls, ns, MODE_S);
ASSERT(ls.isAtLeastReadLocked(ns));
}
- ASSERT(ls.getLockMode(id) == newlm::MODE_NONE);
+ ASSERT(ls.getLockMode(id) == MODE_NONE);
}
} // namespace mongo
diff --git a/src/mongo/db/concurrency/lock_mgr_new.cpp b/src/mongo/db/concurrency/lock_mgr_new.cpp
index f94837d1a89..685c541a9da 100644
--- a/src/mongo/db/concurrency/lock_mgr_new.cpp
+++ b/src/mongo/db/concurrency/lock_mgr_new.cpp
@@ -38,7 +38,6 @@
namespace mongo {
-namespace newlm {
namespace {
@@ -733,5 +732,4 @@ namespace newlm {
recursiveCount = 0;
}
-} // namespace newlm
} // namespace mongo
diff --git a/src/mongo/db/concurrency/lock_mgr_new.h b/src/mongo/db/concurrency/lock_mgr_new.h
index 991c4d69304..21bee164bed 100644
--- a/src/mongo/db/concurrency/lock_mgr_new.h
+++ b/src/mongo/db/concurrency/lock_mgr_new.h
@@ -47,9 +47,6 @@
namespace mongo {
class Locker;
-
-namespace newlm {
-
struct LockHead;
/**
@@ -77,9 +74,6 @@ namespace newlm {
LockModesCount = 5,
};
- // To ensure lock modes are not added without updating the counts
- BOOST_STATIC_ASSERT(LockModesCount == MODE_X + 1);
-
/**
* Return values for the locking functions of the lock manager.
@@ -343,5 +337,4 @@ namespace newlm {
bool _noCheckForLeakedLocksTestOnly;
};
-} // namespace newlm
} // namespace mongo
diff --git a/src/mongo/db/concurrency/lock_mgr_new_test.cpp b/src/mongo/db/concurrency/lock_mgr_new_test.cpp
index 11d77656aee..a5cb80611ff 100644
--- a/src/mongo/db/concurrency/lock_mgr_new_test.cpp
+++ b/src/mongo/db/concurrency/lock_mgr_new_test.cpp
@@ -31,7 +31,6 @@
namespace mongo {
-namespace newlm {
TEST(ResourceId, Semantics) {
ResourceId resIdDb(RESOURCE_DATABASE, 324334234);
@@ -635,5 +634,4 @@ namespace newlm {
checkConflict(MODE_X, MODE_X, true);
}
-} // namespace newlm
} // namespace mongo
diff --git a/src/mongo/db/concurrency/lock_mgr_test_help.h b/src/mongo/db/concurrency/lock_mgr_test_help.h
index a711002284f..f9bf57cfd99 100644
--- a/src/mongo/db/concurrency/lock_mgr_test_help.h
+++ b/src/mongo/db/concurrency/lock_mgr_test_help.h
@@ -32,7 +32,6 @@
#include "mongo/db/concurrency/lock_state.h"
namespace mongo {
-namespace newlm {
class TrackingLockGrantNotification : public LockGrantNotification {
public:
@@ -53,5 +52,4 @@ namespace newlm {
LockResult lastResult;
};
-} // namespace newlm
} // namespace mongo
diff --git a/src/mongo/db/concurrency/lock_state.cpp b/src/mongo/db/concurrency/lock_state.cpp
index 0729efce3f4..e69e149d40e 100644
--- a/src/mongo/db/concurrency/lock_state.cpp
+++ b/src/mongo/db/concurrency/lock_state.cpp
@@ -37,7 +37,6 @@
namespace mongo {
-namespace newlm {
namespace {
@@ -64,8 +63,44 @@ namespace newlm {
const ResourceId resourceIdLocalDB =
ResourceId(RESOURCE_DATABASE, string("local"));
- bool isSharedMode(newlm::LockMode mode) {
- return (mode == newlm::MODE_IS || mode == newlm::MODE_S);
+ /**
+ * Returns whether the passed in mode is S or IS. Used for validation checks.
+ */
+ bool isSharedMode(LockMode mode) {
+ return (mode == MODE_IS || mode == MODE_S);
+ }
+
+ /**
+ * Whether the particular lock's release should be held until the end of the operation.
+ */
+ bool shouldDelayUnlock(const ResourceId& resId, LockMode mode) {
+ // Global and flush lock are not used to protect transactional resources and as such, they
+ // need to be acquired and released when requested.
+ if (resId == resourceIdGlobal) {
+ return false;
+ }
+
+ if (resId == resourceIdMMAPV1Flush) {
+ return false;
+ }
+
+ switch (mode) {
+ // unlocks of exclusive locks are delayed to the end of the WUOW
+ case MODE_X:
+ case MODE_IX:
+ return true;
+
+ // nothing else should be
+ case MODE_IS:
+ case MODE_S:
+ return false;
+
+ // these should never be passed in
+ case MODE_NONE:
+ invariant(false);
+ }
+
+ invariant(false);
}
}
@@ -97,12 +132,12 @@ namespace newlm {
}
const StringData db = nsToDatabaseSubstring(ns);
- const newlm::ResourceId resIdNs(newlm::RESOURCE_DATABASE, db);
+ const ResourceId resIdNs(RESOURCE_DATABASE, db);
- return isLockHeldForMode(resIdNs, newlm::MODE_X);
+ return isLockHeldForMode(resIdNs, MODE_X);
}
- bool LockerImpl::isDbLockedForMode(const StringData& dbName, newlm::LockMode mode) const {
+ bool LockerImpl::isDbLockedForMode(const StringData& dbName, LockMode mode) const {
DEV {
const NamespaceString nss(dbName);
dassert(nss.coll().empty());
@@ -111,7 +146,7 @@ namespace newlm {
if (isW()) return true;
if (isR() && isSharedMode(mode)) return true;
- const newlm::ResourceId resIdDb(newlm::RESOURCE_DATABASE, dbName);
+ const ResourceId resIdDb(RESOURCE_DATABASE, dbName);
return isLockHeldForMode(resIdDb, mode);
}
@@ -124,20 +159,20 @@ namespace newlm {
}
const StringData db = nsToDatabaseSubstring(ns);
- const newlm::ResourceId resIdDb(newlm::RESOURCE_DATABASE, db);
+ const ResourceId resIdDb(RESOURCE_DATABASE, db);
// S on the database means we don't need to check further down the hierarchy
- if (isLockHeldForMode(resIdDb, newlm::MODE_S)) {
+ if (isLockHeldForMode(resIdDb, MODE_S)) {
return true;
}
- if (!isLockHeldForMode(resIdDb, newlm::MODE_IS)) {
+ if (!isLockHeldForMode(resIdDb, MODE_IS)) {
return false;
}
if (nsIsFull(ns)) {
- const newlm::ResourceId resIdColl(newlm::RESOURCE_DATABASE, ns);
- return isLockHeldForMode(resIdColl, newlm::MODE_IS);
+ const ResourceId resIdColl(RESOURCE_DATABASE, ns);
+ return isLockHeldForMode(resIdColl, MODE_IS);
}
// We're just asking about a database, so IS on the db is enough.
@@ -489,38 +524,6 @@ namespace newlm {
return result;
}
-namespace {
- bool shouldDelayUnlock(const ResourceId& resId, LockMode mode) {
- // Global and flush lock are not used to protect transactional resources and as such, they
- // need to be acquired and released when requested.
- if (resId == resourceIdGlobal) {
- return false;
- }
-
- if (resId == resourceIdMMAPV1Flush) {
- return false;
- }
-
- switch (mode) {
- // unlocks of exclusive locks are delayed to the end of the WUOW
- case MODE_X:
- case MODE_IX:
- return true;
-
- // nothing else should be
- case MODE_IS:
- case MODE_S:
- return false;
-
- // these should never be passed in
- case MODE_NONE:
- invariant(false);
- }
-
- invariant(false);
- }
-} // namespace
-
bool LockerImpl::unlock(const ResourceId& resId) {
LockRequest* request = _find(resId);
@@ -743,5 +746,4 @@ namespace {
invariant(_locker->unlock(resourceIdMMAPV1Flush));
}
-} // namespace newlm
} // namespace mongo
diff --git a/src/mongo/db/concurrency/lock_state.h b/src/mongo/db/concurrency/lock_state.h
index 2201a4fc9e0..c321b6415c7 100644
--- a/src/mongo/db/concurrency/lock_state.h
+++ b/src/mongo/db/concurrency/lock_state.h
@@ -35,8 +35,7 @@
namespace mongo {
-namespace newlm {
-
+
/**
* Notfication callback, which stores the last notification result and signals a condition
* variable, which can be waited on.
@@ -217,7 +216,7 @@ namespace newlm {
virtual bool isLocked() const;
virtual bool isWriteLocked() const;
virtual bool isWriteLocked(const StringData& ns) const;
- virtual bool isDbLockedForMode(const StringData& dbName, newlm::LockMode mode) const;
+ virtual bool isDbLockedForMode(const StringData& dbName, LockMode mode) const;
virtual bool isAtLeastReadLocked(const StringData& ns) const;
virtual bool isRecursive() const;
@@ -296,14 +295,12 @@ namespace newlm {
private:
Locker* _locker;
};
-
-} // namespace newlm
/**
* This will go away as a separate step.
*/
- class LockState : public newlm::LockerImpl {
+ class LockState : public LockerImpl {
public:
LockState() { }
diff --git a/src/mongo/db/concurrency/lock_state_test.cpp b/src/mongo/db/concurrency/lock_state_test.cpp
index ee1fd2682d3..80e1e98de3b 100644
--- a/src/mongo/db/concurrency/lock_state_test.cpp
+++ b/src/mongo/db/concurrency/lock_state_test.cpp
@@ -35,7 +35,6 @@
namespace mongo {
-namespace newlm {
TEST(LockerImpl, LockNoConflict) {
const ResourceId resId(RESOURCE_COLLECTION, std::string("TestDB.collection"));
@@ -153,12 +152,12 @@ namespace newlm {
locker.endWriteUnitOfWork();
{
- newlm::AutoYieldFlushLockForMMAPV1Commit flushLockYield(&locker);
+ AutoYieldFlushLockForMMAPV1Commit flushLockYield(&locker);
// This block simulates the flush/remap thread
{
LockerImpl flushLocker(2);
- newlm::AutoAcquireFlushLockForMMAPV1Commit flushLockAcquire(&flushLocker);
+ AutoAcquireFlushLockForMMAPV1Commit flushLockAcquire(&flushLocker);
}
}
@@ -254,5 +253,4 @@ namespace newlm {
locker.unlockAll();
}
-} // namespace newlm
} // namespace mongo
diff --git a/src/mongo/db/concurrency/locker.h b/src/mongo/db/concurrency/locker.h
index e8d68eafdd3..02974ddce21 100644
--- a/src/mongo/db/concurrency/locker.h
+++ b/src/mongo/db/concurrency/locker.h
@@ -75,7 +75,7 @@ namespace mongo {
* acquired within the specified time bound. Otherwise, the respective failure
* code and neither lock will be acquired.
*/
- virtual newlm::LockResult lockGlobal(newlm::LockMode mode,
+ virtual LockResult lockGlobal(LockMode mode,
unsigned timeoutMs = UINT_MAX) = 0;
/**
@@ -127,8 +127,8 @@ namespace mongo {
*
* @return All LockResults except for LOCK_WAITING, because it blocks.
*/
- virtual newlm::LockResult lock(const newlm::ResourceId& resId,
- newlm::LockMode mode,
+ virtual LockResult lock(const ResourceId& resId,
+ LockMode mode,
unsigned timeoutMs = UINT_MAX) = 0;
/**
@@ -138,7 +138,7 @@ namespace mongo {
* @return true if the lock was actually released; false if only the reference count was
* decremented, but the lock is still held.
*/
- virtual bool unlock(const newlm::ResourceId& resId) = 0;
+ virtual bool unlock(const ResourceId& resId) = 0;
/**
* Retrieves the mode in which a lock is held or checks whether the lock held for a
@@ -147,9 +147,9 @@ namespace mongo {
* For example isLockHeldForMode will return true for MODE_S, if MODE_X is already held,
* because MODE_X covers MODE_S.
*/
- virtual newlm::LockMode getLockMode(const newlm::ResourceId& resId) const = 0;
- virtual bool isLockHeldForMode(const newlm::ResourceId& resId,
- newlm::LockMode mode) const = 0;
+ virtual LockMode getLockMode(const ResourceId& resId) const = 0;
+ virtual bool isLockHeldForMode(const ResourceId& resId,
+ LockMode mode) const = 0;
/**
* LockSnapshot captures the state of all resources that are locked, what modes they're
@@ -157,17 +157,17 @@ namespace mongo {
*/
struct LockSnapshot {
// The global lock is handled differently from all other locks.
- newlm::LockMode globalMode;
+ LockMode globalMode;
// One can acquire the global lock repeatedly.
unsigned globalRecursiveCount;
struct OneLock {
// What lock resource is held?
- newlm::ResourceId resourceId;
+ ResourceId resourceId;
// In what mode is it held?
- newlm::LockMode mode;
+ LockMode mode;
// What's the recursive count of this lock? Note that we don't store any state
// about how we got this lock (eg upgrade), just how many times we've locked it
@@ -222,7 +222,7 @@ namespace mongo {
virtual bool isLocked() const = 0;
virtual bool isWriteLocked() const = 0;
virtual bool isWriteLocked(const StringData& ns) const = 0;
- virtual bool isDbLockedForMode(const StringData& dbName, newlm::LockMode mode) const = 0;
+ virtual bool isDbLockedForMode(const StringData& dbName, LockMode mode) const = 0;
virtual bool isAtLeastReadLocked(const StringData& ns) const = 0;
virtual bool isRecursive() const = 0;
diff --git a/src/mongo/db/concurrency/resource_id.h b/src/mongo/db/concurrency/resource_id.h
index b5503fba9d5..8631619d37b 100644
--- a/src/mongo/db/concurrency/resource_id.h
+++ b/src/mongo/db/concurrency/resource_id.h
@@ -37,7 +37,6 @@
namespace mongo {
-namespace newlm {
/**
* Hierarchy of resource types. The lock manager knows nothing about this hierarchy, it is
@@ -115,13 +114,12 @@ namespace newlm {
//
// BOOST_STATIC_ASSERT(sizeof(ResourceId) == sizeof(uint64_t));
-} // namespace newlm
} // namespace mongo
MONGO_HASH_NAMESPACE_START
- template <> struct hash<mongo::newlm::ResourceId> {
- size_t operator()(const mongo::newlm::ResourceId& resource) const {
+ template <> struct hash<mongo::ResourceId> {
+ size_t operator()(const mongo::ResourceId& resource) const {
return resource;
}
};
diff --git a/src/mongo/db/dbcommands.cpp b/src/mongo/db/dbcommands.cpp
index 4b010e4ce9b..992eb942ca2 100644
--- a/src/mongo/db/dbcommands.cpp
+++ b/src/mongo/db/dbcommands.cpp
@@ -349,7 +349,7 @@ namespace mongo {
// Needs to be locked exclusively, because creates the system.profile collection
// in the local database.
//
- Lock::DBLock dbXLock(txn->lockState(), dbname, newlm::MODE_X);
+ Lock::DBLock dbXLock(txn->lockState(), dbname, MODE_X);
Client::Context ctx(txn, dbname);
BSONElement e = cmdObj.firstElement();
@@ -404,7 +404,7 @@ namespace mongo {
// This doesn't look like it requires exclusive DB lock, because it uses its own diag
// locking, but originally the lock was set to be WRITE, so preserving the behaviour.
//
- Lock::DBLock dbXLock(txn->lockState(), dbname, newlm::MODE_X);
+ Lock::DBLock dbXLock(txn->lockState(), dbname, MODE_X);
Client::Context ctx(txn, dbname);
int was = _diaglog.setLevel( cmdObj.firstElement().numberInt() );
@@ -460,7 +460,7 @@ namespace mongo {
return false;
}
- Lock::DBLock dbXLock(txn->lockState(), dbname, newlm::MODE_X);
+ Lock::DBLock dbXLock(txn->lockState(), dbname, MODE_X);
WriteUnitOfWork wunit(txn);
Client::Context ctx(txn, nsToDrop);
Database* db = ctx.db();
@@ -560,7 +560,7 @@ namespace mongo {
!options["capped"].trueValue() || options["size"].isNumber() ||
options.hasField("$nExtents"));
- Lock::DBLock dbXLock(txn->lockState(), dbname, newlm::MODE_X);
+ Lock::DBLock dbXLock(txn->lockState(), dbname, MODE_X);
WriteUnitOfWork wunit(txn);
Client::Context ctx(txn, ns);
@@ -951,7 +951,7 @@ namespace mongo {
bool run(OperationContext* txn, const string& dbname, BSONObj& jsobj, int, string& errmsg, BSONObjBuilder& result, bool fromRepl ) {
const string ns = dbname + "." + jsobj.firstElement().valuestr();
- Lock::DBLock dbXLock(txn->lockState(), dbname, newlm::MODE_X);
+ Lock::DBLock dbXLock(txn->lockState(), dbname, MODE_X);
WriteUnitOfWork wunit(txn);
Client::Context ctx(txn, ns );
@@ -1095,7 +1095,7 @@ namespace mongo {
// We lock the entire database in S-mode in order to ensure that the contents will not
// change for the stats snapshot. This might be unnecessary and if it becomes a
// performance issue, we can take IS lock and then lock collection-by-collection.
- AutoGetDb autoDb(txn, ns, newlm::MODE_S);
+ AutoGetDb autoDb(txn, ns, MODE_S);
result.append("db", ns);
diff --git a/src/mongo/db/exec/stagedebug_cmd.cpp b/src/mongo/db/exec/stagedebug_cmd.cpp
index e2db4f3a120..75bcfb3dce9 100644
--- a/src/mongo/db/exec/stagedebug_cmd.cpp
+++ b/src/mongo/db/exec/stagedebug_cmd.cpp
@@ -121,7 +121,7 @@ namespace mongo {
// TODO A write lock is currently taken here to accommodate stages that perform writes
// (e.g. DeleteStage). This should be changed to use a read lock for read-only
// execution trees.
- Lock::DBLock lk(txn->lockState(), dbname, newlm::MODE_X);
+ Lock::DBLock lk(txn->lockState(), dbname, MODE_X);
Client::Context ctx(txn, dbname);
// Make sure the collection is valid.
diff --git a/src/mongo/db/index_builder.cpp b/src/mongo/db/index_builder.cpp
index 737cb4d1196..915b468891b 100644
--- a/src/mongo/db/index_builder.cpp
+++ b/src/mongo/db/index_builder.cpp
@@ -71,7 +71,7 @@ namespace mongo {
txn.getCurOp()->reset(HostAndPort(), dbInsert);
NamespaceString ns(_index["ns"].String());
- Lock::DBLock dlk(txn.lockState(), ns.db(), newlm::MODE_X);
+ Lock::DBLock dlk(txn.lockState(), ns.db(), MODE_X);
Client::Context ctx(&txn, ns.getSystemIndexesCollection());
Database* db = dbHolder().get(&txn, ns.db().toString());
diff --git a/src/mongo/db/index_rebuilder.cpp b/src/mongo/db/index_rebuilder.cpp
index fa494c5f220..58bb3b98501 100644
--- a/src/mongo/db/index_rebuilder.cpp
+++ b/src/mongo/db/index_rebuilder.cpp
@@ -64,7 +64,7 @@ namespace {
// This write lock is held throughout the index building process
// for this namespace.
- Lock::DBLock lk(txn->lockState(), nsToDatabaseSubstring(ns), newlm::MODE_X);
+ Lock::DBLock lk(txn->lockState(), nsToDatabaseSubstring(ns), MODE_X);
Client::Context ctx(txn, ns);
Collection* collection = ctx.db()->getCollection(txn, ns);
@@ -147,7 +147,7 @@ namespace {
for (std::vector<std::string>::const_iterator dbName = dbNames.begin();
dbName < dbNames.end();
++dbName) {
- AutoGetDb autoDb(txn, *dbName, newlm::MODE_S);
+ AutoGetDb autoDb(txn, *dbName, MODE_S);
Database* db = autoDb.getDb();
db->getDatabaseCatalogEntry()->getCollectionNamespaces(&collNames);
diff --git a/src/mongo/db/instance.cpp b/src/mongo/db/instance.cpp
index e2f53df9ef3..67fa4f2c00c 100644
--- a/src/mongo/db/instance.cpp
+++ b/src/mongo/db/instance.cpp
@@ -623,8 +623,8 @@ namespace mongo {
{
// Tentatively take an intent lock, fix up if we need to create the collection
- Lock::DBLock dbLock(txn->lockState(), ns.db(), newlm::MODE_IX);
- Lock::CollectionLock colLock(txn->lockState(), ns.ns(), newlm::MODE_IX);
+ Lock::DBLock dbLock(txn->lockState(), ns.db(), MODE_IX);
+ Lock::CollectionLock colLock(txn->lockState(), ns.ns(), MODE_IX);
Client::Context ctx(txn, ns);
// The common case: no implicit collection creation
@@ -640,7 +640,7 @@ namespace mongo {
// This is an upsert into a non-existing database, so need an exclusive lock
// to avoid deadlock
{
- Lock::DBLock dbLock(txn->lockState(), ns.db(), newlm::MODE_X);
+ Lock::DBLock dbLock(txn->lockState(), ns.db(), MODE_X);
Client::Context ctx(txn, ns);
UpdateResult res = executor.execute(ctx.db());
lastError.getSafe()->recordUpdate( res.existing , res.numMatched , res.upserted );
@@ -672,8 +672,8 @@ namespace mongo {
DeleteExecutor executor(&request);
uassertStatusOK(executor.prepare());
- Lock::DBLock dbLocklk(txn->lockState(), ns.db(), newlm::MODE_IX);
- Lock::CollectionLock colLock(txn->lockState(), ns.ns(), newlm::MODE_IX);
+ Lock::DBLock dbLocklk(txn->lockState(), ns.db(), MODE_IX);
+ Lock::CollectionLock colLock(txn->lockState(), ns.ns(), MODE_IX);
Client::Context ctx(txn, ns);
long long n = executor.execute(ctx.db());
@@ -935,7 +935,7 @@ namespace mongo {
const int notMasterCodeForInsert = 10058; // This is different from ErrorCodes::NotMaster
{
const bool isIndexBuild = (nsToCollectionSubstring(ns) == "system.indexes");
- const newlm::LockMode mode = isIndexBuild ? newlm::MODE_X : newlm::MODE_IX;
+ const LockMode mode = isIndexBuild ? MODE_X : MODE_IX;
Lock::DBLock dbLock(txn->lockState(), nsString.db(), mode);
Lock::CollectionLock collLock(txn->lockState(), nsString.ns(), mode);
@@ -945,7 +945,7 @@ namespace mongo {
repl::getGlobalReplicationCoordinator()->canAcceptWritesForDatabase(nsString.db()));
Client::Context ctx(txn, ns);
- if (mode == newlm::MODE_X || ctx.db()->getCollection(txn, nsString)) {
+ if (mode == MODE_X || ctx.db()->getCollection(txn, nsString)) {
if (multi.size() > 1) {
const bool keepGoing = d.reservedField() & InsertOption_ContinueOnError;
insertMulti(txn, ctx, keepGoing, ns, multi, op);
@@ -959,7 +959,7 @@ namespace mongo {
}
// Collection didn't exist so try again with MODE_X
- Lock::DBLock dbLock(txn->lockState(), nsString.db(), newlm::MODE_X);
+ Lock::DBLock dbLock(txn->lockState(), nsString.db(), MODE_X);
// CONCURRENCY TODO: is being read locked in big log sufficient here?
// writelock is used to synchronize stepdowns w/ writes
diff --git a/src/mongo/db/introspect.cpp b/src/mongo/db/introspect.cpp
index aa6cf2eda1f..1aac02076d6 100644
--- a/src/mongo/db/introspect.cpp
+++ b/src/mongo/db/introspect.cpp
@@ -138,7 +138,7 @@ namespace {
// NOTE: It's kind of weird that we lock the op's namespace, but have to for now
// since we're sometimes inside the lock already
const string dbname(nsToDatabase(currentOp.getNS()));
- Lock::DBLock lk(txn->lockState(), dbname, newlm::MODE_X);
+ Lock::DBLock lk(txn->lockState(), dbname, MODE_X);
if (dbHolder().get(txn, dbname) != NULL) {
// We are ok with the profiling happening in a different WUOW from the actual op.
WriteUnitOfWork wunit(txn);
diff --git a/src/mongo/db/operation_context_impl.cpp b/src/mongo/db/operation_context_impl.cpp
index a7f66d5452a..31bac237f05 100644
--- a/src/mongo/db/operation_context_impl.cpp
+++ b/src/mongo/db/operation_context_impl.cpp
@@ -48,7 +48,7 @@ namespace mongo {
invariant(storageEngine);
_recovery.reset(storageEngine->newRecoveryUnit(this));
- _locker.reset(new newlm::LockerImpl());
+ _locker.reset(new LockerImpl());
getGlobalEnvironment()->registerOperationContext(this);
}
diff --git a/src/mongo/db/ops/update_executor.cpp b/src/mongo/db/ops/update_executor.cpp
index 12bb3e89a73..efa88679628 100644
--- a/src/mongo/db/ops/update_executor.cpp
+++ b/src/mongo/db/ops/update_executor.cpp
@@ -124,7 +124,7 @@ namespace mongo {
LOG(0) << "About to upgrade to exclusive lock on " + nsString.ns();
}
- Lock::DBLock lk(txn->lockState(), nsString.db(), newlm::MODE_X);
+ Lock::DBLock lk(txn->lockState(), nsString.db(), MODE_X);
WriteUnitOfWork wuow(txn);
invariant(db->createCollection(txn, nsString.ns()));
diff --git a/src/mongo/db/prefetch.cpp b/src/mongo/db/prefetch.cpp
index 958f6039046..7638320722f 100644
--- a/src/mongo/db/prefetch.cpp
+++ b/src/mongo/db/prefetch.cpp
@@ -175,7 +175,7 @@ namespace {
// This will have to change for engines other than MMAP V1, because they might not have
// means for directly prefetching pages from the collection. For this purpose, acquire S
// lock on the database, instead of optimizing with IS.
- Lock::CollectionLock collLock(txn->lockState(), ns, newlm::MODE_S);
+ Lock::CollectionLock collLock(txn->lockState(), ns, MODE_S);
Collection* collection = db->getCollection( txn, ns );
if (!collection) {
diff --git a/src/mongo/db/repl/master_slave.cpp b/src/mongo/db/repl/master_slave.cpp
index 123d52bf344..ff66e43cdbc 100644
--- a/src/mongo/db/repl/master_slave.cpp
+++ b/src/mongo/db/repl/master_slave.cpp
@@ -168,7 +168,7 @@ namespace repl {
bool exists = Helpers::getSingleton(txn, "local.me", _me);
if (!exists || !_me.hasField("host") || _me["host"].String() != myname) {
- Lock::DBLock dblk(txn->lockState(), "local", newlm::MODE_X);
+ Lock::DBLock dblk(txn->lockState(), "local", MODE_X);
WriteUnitOfWork wunit(txn);
// clean out local.me
Helpers::emptyCollection(txn, "local.me");
diff --git a/src/mongo/db/repl/minvalid.cpp b/src/mongo/db/repl/minvalid.cpp
index 47620adbb06..db4afb3e345 100644
--- a/src/mongo/db/repl/minvalid.cpp
+++ b/src/mongo/db/repl/minvalid.cpp
@@ -49,14 +49,14 @@ namespace {
} // namespace
void clearInitialSyncFlag(OperationContext* txn) {
- Lock::DBLock lk(txn->lockState(), "local", newlm::MODE_X);
+ Lock::DBLock lk(txn->lockState(), "local", MODE_X);
WriteUnitOfWork wunit(txn);
Helpers::putSingleton(txn, minvalidNS, BSON("$unset" << initialSyncFlag));
wunit.commit();
}
void setInitialSyncFlag(OperationContext* txn) {
- Lock::DBLock lk(txn->lockState(), "local", newlm::MODE_X);
+ Lock::DBLock lk(txn->lockState(), "local", MODE_X);
WriteUnitOfWork wunit(txn);
Helpers::putSingleton(txn, minvalidNS, BSON("$set" << initialSyncFlag));
wunit.commit();
@@ -72,7 +72,7 @@ namespace {
}
void setMinValid(OperationContext* ctx, OpTime ts) {
- Lock::DBLock lk(ctx->lockState(), "local", newlm::MODE_X);
+ Lock::DBLock lk(ctx->lockState(), "local", MODE_X);
WriteUnitOfWork wunit(ctx);
Helpers::putSingleton(ctx, minvalidNS, BSON("$set" << BSON("ts" << ts)));
wunit.commit();
diff --git a/src/mongo/db/repl/oplog.cpp b/src/mongo/db/repl/oplog.cpp
index 12596e0ce63..8f22452d69f 100644
--- a/src/mongo/db/repl/oplog.cpp
+++ b/src/mongo/db/repl/oplog.cpp
@@ -120,7 +120,7 @@ namespace repl {
todo : make _logOpRS() call this so we don't repeat ourself?
*/
OpTime _logOpObjRS(OperationContext* txn, const BSONObj& op) {
- Lock::DBLock lk(txn->lockState(), "local", newlm::MODE_X);
+ Lock::DBLock lk(txn->lockState(), "local", MODE_X);
// XXX soon this needs to be part of an outer WUOW not its own.
// We can't do this yet due to locking limitations.
WriteUnitOfWork wunit(txn);
@@ -237,7 +237,7 @@ namespace repl {
BSONObj *o2,
bool *bb,
bool fromMigrate ) {
- Lock::DBLock lk1(txn->lockState(), "local", newlm::MODE_X);
+ Lock::DBLock lk1(txn->lockState(), "local", MODE_X);
WriteUnitOfWork wunit(txn);
if ( strncmp(ns, "local.", 6) == 0 ) {
@@ -321,7 +321,7 @@ namespace repl {
BSONObj *o2,
bool *bb,
bool fromMigrate ) {
- Lock::DBLock lk(txn->lockState(), "local", newlm::MODE_X);
+ Lock::DBLock lk(txn->lockState(), "local", MODE_X);
WriteUnitOfWork wunit(txn);
static BufBuilder bufbuilder(8*1024); // todo there is likely a mutex on this constructor
diff --git a/src/mongo/db/repl/repl_coordinator_external_state_impl.cpp b/src/mongo/db/repl/repl_coordinator_external_state_impl.cpp
index 4d359bd023e..ae4509f027a 100644
--- a/src/mongo/db/repl/repl_coordinator_external_state_impl.cpp
+++ b/src/mongo/db/repl/repl_coordinator_external_state_impl.cpp
@@ -102,7 +102,7 @@ namespace {
std::string myname = getHostName();
OID myRID;
{
- Lock::DBLock lock(txn->lockState(), meDatabaseName, newlm::MODE_X);
+ Lock::DBLock lock(txn->lockState(), meDatabaseName, MODE_X);
BSONObj me;
// local.me is an identifier for a server for getLastError w:2+
@@ -148,7 +148,7 @@ namespace {
OperationContext* txn,
const BSONObj& config) {
try {
- Lock::DBLock dbWriteLock(txn->lockState(), configDatabaseName, newlm::MODE_X);
+ Lock::DBLock dbWriteLock(txn->lockState(), configDatabaseName, MODE_X);
Helpers::putSingleton(txn, configCollectionName, config);
return Status::OK();
}
diff --git a/src/mongo/db/repl/rs_initialsync.cpp b/src/mongo/db/repl/rs_initialsync.cpp
index 0226547127d..6799d5df3c3 100644
--- a/src/mongo/db/repl/rs_initialsync.cpp
+++ b/src/mongo/db/repl/rs_initialsync.cpp
@@ -84,7 +84,7 @@ namespace {
options.syncIndexes = ! dataPass;
// Make database stable
- Lock::DBLock dbWrite(txn->lockState(), db, newlm::MODE_X);
+ Lock::DBLock dbWrite(txn->lockState(), db, MODE_X);
if (!cloner.go(txn, db, host, options, NULL, err, &errCode)) {
log() << "initial sync: error while "
@@ -280,7 +280,7 @@ namespace {
log() << "initial sync finishing up";
{
- AutoGetDb autodb(&txn, "local", newlm::MODE_X);
+ AutoGetDb autodb(&txn, "local", MODE_X);
WriteUnitOfWork wunit(&txn);
OpTime lastOpTimeWritten(getGlobalReplicationCoordinator()->getMyLastOptime());
log() << "replSet set minValid=" << lastOpTimeWritten << rsLog;
diff --git a/src/mongo/db/repl/sync_source_feedback.cpp b/src/mongo/db/repl/sync_source_feedback.cpp
index 28cb8c12384..ab285fedb72 100644
--- a/src/mongo/db/repl/sync_source_feedback.cpp
+++ b/src/mongo/db/repl/sync_source_feedback.cpp
@@ -78,7 +78,7 @@ namespace repl {
void SyncSourceFeedback::ensureMe(OperationContext* txn) {
string myname = getHostName();
{
- Lock::DBLock dlk(txn->lockState(), "local", newlm::MODE_X);
+ Lock::DBLock dlk(txn->lockState(), "local", MODE_X);
WriteUnitOfWork wunit(txn);
Client::Context ctx(txn, "local");
diff --git a/src/mongo/db/repl/sync_tail.cpp b/src/mongo/db/repl/sync_tail.cpp
index 683990a5dab..dd341ee4ea1 100644
--- a/src/mongo/db/repl/sync_tail.cpp
+++ b/src/mongo/db/repl/sync_tail.cpp
@@ -124,7 +124,7 @@ namespace repl {
lk.reset(new Lock::GlobalWrite(txn->lockState()));
} else {
// DB level lock for this operation
- lk.reset(new Lock::DBLock(txn->lockState(), nsToDatabaseSubstring(ns), newlm::MODE_X));
+ lk.reset(new Lock::DBLock(txn->lockState(), nsToDatabaseSubstring(ns), MODE_X));
}
Client::Context ctx(txn, ns);
@@ -332,7 +332,7 @@ namespace {
BackgroundSync* bgsync = BackgroundSync::get();
if (bgsync->getInitialSyncRequestedFlag()) {
// got a resync command
- Lock::DBLock lk(txn.lockState(), "local", newlm::MODE_X);
+ Lock::DBLock lk(txn.lockState(), "local", MODE_X);
WriteUnitOfWork wunit(&txn);
Client::Context ctx(&txn, "local");
@@ -500,7 +500,7 @@ namespace {
OpTime lastOpTime;
{
OperationContextImpl txn; // XXX?
- Lock::DBLock lk(txn.lockState(), "local", newlm::MODE_X);
+ Lock::DBLock lk(txn.lockState(), "local", MODE_X);
WriteUnitOfWork wunit(&txn);
while (!ops->empty()) {
diff --git a/src/mongo/db/storage/mmap_v1/dur.cpp b/src/mongo/db/storage/mmap_v1/dur.cpp
index 71bb5c4f2c8..47357b21141 100644
--- a/src/mongo/db/storage/mmap_v1/dur.cpp
+++ b/src/mongo/db/storage/mmap_v1/dur.cpp
@@ -231,7 +231,7 @@ namespace mongo {
NotifyAll::When when = commitJob._notify.now();
- newlm::AutoYieldFlushLockForMMAPV1Commit flushLockYield(txn->lockState());
+ AutoYieldFlushLockForMMAPV1Commit flushLockYield(txn->lockState());
// There is always just one waiting anyways
flushRequested.notify_one();
@@ -653,7 +653,7 @@ namespace mongo {
// Waits for all active operations to drain and won't let new ones start. This
// should be optimized to allow readers in (see SERVER-15262).
- newlm::AutoAcquireFlushLockForMMAPV1Commit flushLock(txn.lockState());
+ AutoAcquireFlushLockForMMAPV1Commit flushLock(txn.lockState());
groupCommit();
remapPrivateView();