diff options
author | Geert Bosch <geert@mongodb.com> | 2014-11-20 14:26:43 -0500 |
---|---|---|
committer | Geert Bosch <geert@mongodb.com> | 2014-11-21 13:18:53 -0500 |
commit | e7f6c56327afa51847a95d9d5bc6399209856c10 (patch) | |
tree | 93a6f8b98d13ff81bd21a2ffc9f312e4ff662123 /src/mongo/db/dbcommands.cpp | |
parent | e5644e2ca12a60df677cb8e8dfc70f19a9423b0a (diff) | |
download | mongo-e7f6c56327afa51847a95d9d5bc6399209856c10.tar.gz |
SERVER-16192: Add ScopedTransaction to automatically commitAndRestart()
Diffstat (limited to 'src/mongo/db/dbcommands.cpp')
-rw-r--r-- | src/mongo/db/dbcommands.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/mongo/db/dbcommands.cpp b/src/mongo/db/dbcommands.cpp index 0c6164f8f3a..6ffe89f1820 100644 --- a/src/mongo/db/dbcommands.cpp +++ b/src/mongo/db/dbcommands.cpp @@ -202,6 +202,7 @@ namespace mongo { { // TODO: SERVER-4328 Don't lock globally + ScopedTransaction transaction(txn, MODE_X); Lock::GlobalWrite lk(txn->lockState()); if (dbHolder().get(txn, dbname) == NULL) { return true; // didn't exist, was no-op @@ -286,6 +287,7 @@ namespace mongo { } // TODO: SERVER-4328 Don't lock globally + ScopedTransaction transaction(txn, MODE_X); Lock::GlobalWrite lk(txn->lockState()); Client::Context context(txn, dbname ); @@ -358,6 +360,7 @@ namespace mongo { // Needs to be locked exclusively, because creates the system.profile collection // in the local database. // + ScopedTransaction transaction(txn, MODE_IX); Lock::DBLock dbXLock(txn->lockState(), dbname, MODE_X); Client::Context ctx(txn, dbname); @@ -413,6 +416,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. // + ScopedTransaction transaction(txn, MODE_IX); Lock::DBLock dbXLock(txn->lockState(), dbname, MODE_X); Client::Context ctx(txn, dbname); @@ -482,6 +486,7 @@ namespace mongo { return false; } + ScopedTransaction transaction(txn, MODE_IX); Lock::DBLock dbXLock(txn->lockState(), dbname, MODE_X); Client::Context ctx(txn, nsToDrop); Database* db = ctx.db(); @@ -582,6 +587,7 @@ namespace mongo { !options["capped"].trueValue() || options["size"].isNumber() || options.hasField("$nExtents")); + ScopedTransaction transaction(txn, MODE_IX); Lock::DBLock dbXLock(txn->lockState(), dbname, MODE_X); WriteUnitOfWork wunit(txn); Client::Context ctx(txn, ns); @@ -998,6 +1004,7 @@ namespace mongo { const std::string ns = dbname + "." + collName; + ScopedTransaction transaction(txn, MODE_IX); Lock::DBLock dbXLock(txn->lockState(), dbname, MODE_X); WriteUnitOfWork wunit(txn); Client::Context ctx(txn, ns ); |