summaryrefslogtreecommitdiff
path: root/src/mongo/db/commands/apply_ops.cpp
diff options
context:
space:
mode:
authorGeert Bosch <geert@mongodb.com>2014-09-25 14:41:01 -0400
committerGeert Bosch <geert@mongodb.com>2014-09-25 18:12:34 -0400
commit962f959a09b63aa0482d7e0c9bad89363d1e1194 (patch)
tree975a9ff722ec19992c15feb9d3fd1587278afc3c /src/mongo/db/commands/apply_ops.cpp
parent77b00970997d13d0758c745e5a94fc79982d4401 (diff)
downloadmongo-962f959a09b63aa0482d7e0c9bad89363d1e1194.tar.gz
SERVER-14668: Replace uses of DBWrite lock with DBLock
Make the lock mode explicit as preparation to move some to intent locks, and use proper database name instead of full namespace string to lock databases.
Diffstat (limited to 'src/mongo/db/commands/apply_ops.cpp')
-rw-r--r--src/mongo/db/commands/apply_ops.cpp26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/mongo/db/commands/apply_ops.cpp b/src/mongo/db/commands/apply_ops.cpp
index c0a1f398e56..cc760412120 100644
--- a/src/mongo/db/commands/apply_ops.cpp
+++ b/src/mongo/db/commands/apply_ops.cpp
@@ -126,26 +126,26 @@ namespace mongo {
string ns = temp["ns"].String();
- // Run operations under a nested lock as a hack to prevent them from yielding.
+ // Run operations under a nested lock as a hack to prevent yielding.
//
- // The list of operations is supposed to be applied atomically; yielding would break
- // atomicity by allowing an interruption or a shutdown to occur after only some
- // operations are applied. We are already locked globally at this point, so taking
- // a DBWrite on the namespace creates a nested lock, and yields are disallowed for
- // operations that hold a nested lock.
+ // The list of operations is supposed to be applied atomically; yielding
+ // would break atomicity by allowing an interruption or a shutdown to occur
+ // after only some operations are applied. We are already locked globally
+ // at this point, so taking a DBLock on the namespace creates a nested lock,
+ // and yields are disallowed for operations that hold a nested lock.
//
- // We do not have a wrapping WriteUnitOfWork so it is possible for a journal commit
- // to happen with a subset of ops applied.
+ // 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::DBWrite lk(txn->lockState(), ns);
+ Lock::DBLock lk(txn->lockState(), nsToDatabaseSubstring(ns), newlm::MODE_X);
invariant(txn->lockState()->isRecursive());
Client::Context ctx(txn, ns);
bool failed = repl::applyOperation_inlock(txn,
- ctx.db(),
- temp,
- false,
- alwaysUpsert);
+ ctx.db(),
+ temp,
+ false,
+ alwaysUpsert);
ab.append(!failed);
if ( failed )
errors++;